# RubyLLM::Models < Object

---
# Includes:
Enumerable
---
A Models registry is the catalog of AI models RubyLLM knows about, including their capabilities, context windows, and pricing. The global registry is available through RubyLLM.models.

    RubyLLM.models.find 'claude-sonnet-4-6'
    RubyLLM.models.by_provider(:openai).chat_models
    RubyLLM.models.refresh!

Filter methods return new Models instances, so calls chain. Models is enumerable over its Model entries. Class-level calls such as Models.find delegate to the global registry.
---
# Class methods:

    refresh!

# Instance methods:

    all
    audio_models
    by_family
    by_provider
    chat_models
    each
    embedding_models
    find
    image_models
    load_from_database!
    load_from_json!
    refresh!
    save_to_json

# RubyLLM::Models::refresh!
### Implementation from Models
---
    refresh!(remote_only: false)

---

Refreshes the global model registry from the published catalog and configured providers. Returns the global Models instance. See #refresh! for the `remote_only:` option.

# RubyLLM::Models#all
### Implementation from Models
---
    all()

---

Returns an array of all Model entries in this registry.

# RubyLLM::Models#audio_models
### Implementation from Models
---
    audio_models()

---

Returns a new Models registry containing only models with audio output.

# RubyLLM::Models#by_family
### Implementation from Models
---
    by_family(family)

---

Returns a new Models registry containing only models in `family`.

    RubyLLM.models.by_family('claude3_sonnet')

# RubyLLM::Models#by_provider
### Implementation from Models
---
    by_provider(provider)

---

Returns a new Models registry containing only models from `provider`. Accepts a symbol or a string.

    RubyLLM.models.by_provider(:openai).select(&:supports_vision?)

# RubyLLM::Models#chat_models
### Implementation from Models
---
    chat_models()

---

Returns a new Models registry containing only chat models.

# RubyLLM::Models#each
### Implementation from Models
---
    each(&)

---

Yields each Model in the registry.

    RubyLLM.models.each { |model| puts model.id }

# RubyLLM::Models#embedding_models
### Implementation from Models
---
    embedding_models()

---

Returns a new Models registry containing only embedding models.

# RubyLLM::Models#find
### Implementation from Models
---
    find(model_id, provider = nil)

---

Returns the Model matching `model_id`, resolving aliases along the way. Without `provider`, picks the preferred provider that carries the model, first-party providers before aggregators. Raises RubyLLM::ModelNotFoundError if no model matches.

    RubyLLM.models.find 'gpt-5.4'
    RubyLLM.models.find 'claude-sonnet-4-6', :bedrock

# RubyLLM::Models#image_models
### Implementation from Models
---
    image_models()

---

Returns a new Models registry containing only models with image output.

# RubyLLM::Models#load_from_database!
### Implementation from Models
---
    load_from_database!()

---

Replaces the models in this registry with rows read from the configured ActiveRecord model registry class (`RubyLLM.config.model_registry_class`).

# RubyLLM::Models#load_from_json!
### Implementation from Models
---
    load_from_json!(file = RubyLLM.config.model_registry_file)

---

Replaces the models in this registry with those read from the JSON `file`. The default is the configured `RubyLLM.config.model_registry_file`. A missing or invalid file falls back to the registry bundled with the gem.

# RubyLLM::Models#refresh!
### Implementation from Models
---
    refresh!(remote_only: false)

---

Replaces the registry with the latest published RubyLLM catalog, merged with models discovered from configured providers. The result is saved to the platform cache, or to the database in Rails applications. Pass `remote_only:` `true` to skip local providers such as Ollama and GPUStack. Returns `self`.

Raises ModelRegistryError when the catalog cannot be fetched or the result cannot be persisted, leaving the current registry unchanged.

    RubyLLM.models.refresh!
    RubyLLM.models.refresh!(remote_only: true).chat_models

# RubyLLM::Models#save_to_json
### Implementation from Models
---
    save_to_json(file = RubyLLM.config.model_registry_file)

---

Exports this registry to `file` as pretty-printed JSON. The default is the configured `RubyLLM.config.model_registry_file`. A regular #refresh! already persists to the active registry store.

    RubyLLM.models.save_to_json('/tmp/models.json')
