class RubyLLM::Model
A Model describes one entry in the model registry: the model’s identity, capabilities, modalities, pricing, and provider metadata. Instances come from the registry through RubyLLM.models and from Chat#model.
model = RubyLLM.models.find('gpt-5.6') model.name # => "GPT-5.6" model.provider # => "openai" model.context_window # => 1050000 model.supports?(:vision) # => true
Attributes
The model’s capability names as an array of Strings, e.g. ["function_calling", "streaming"].
The maximum number of input tokens the model accepts, or nil.
The model’s release timestamp as a UTC Time, or nil.
The model family as a String, e.g. "gpt", or nil.
The provider’s identifier for the model, e.g. "gpt-5.6".
The model’s training data cutoff as a Date, or nil.
The maximum number of tokens the model can generate, or nil.
Provider-specific metadata as a Hash.
The supported input and output modalities as a Model::Modalities object.
model.modalities.input # => ["text", "image", "pdf"] model.modalities.output # => ["text"]
The human-readable model name, e.g. "GPT-5.6".
The model’s pricing as a Model::Pricing object, in USD per million tokens.
The provider slug as a String, e.g. "openai".
The time the configured provider stopped listing the model, as a UTC Time, or nil while the provider still lists it. Only a store that keeps unlisted entries, such as the Rails model table, sets it.
Public Instance Methods
# File lib/ruby_llm/model.rb, line 160 def cost_for(tokens, tier: :standard) tokens = tokens.tokens if tokens.respond_to?(:tokens) Cost.new(tokens:, model: self, tier:) end
Source
# File lib/ruby_llm/model.rb, line 115 def label provider_name = provider_class&.display_name || provider "#{provider_name} - #{name}" end
Returns the provider display name and model name combined, e.g. "OpenAI - GPT-5.6".
Source
# File lib/ruby_llm/model.rb, line 145 def price(kind) column = PRICES.fetch(kind) do raise ArgumentError, "Unknown price kind: #{kind.inspect}. Valid kinds: #{PRICES.keys.join(', ')}" end pricing.text_tokens.public_send(column) end
Returns the standard text-token price for kind in USD per million tokens, or nil if the registry has no such price. Valid kinds are :input, :output, :cache_read, and :cache_write.
model.price(:input) # => 2.5 model.price(:output) # => 10.0
Source
# File lib/ruby_llm/model.rb, line 168 def provider_class RubyLLM::Provider.resolve provider end
Returns the Provider class registered for this model’s provider slug, or nil if no such provider is registered.
Source
# File lib/ruby_llm/model.rb, line 99 def supports?(capability) capabilities.include?(capability.to_s) end
Returns whether capabilities includes capability, given as a String or Symbol.
model.supports?(:function_calling) # => true
Source
# File lib/ruby_llm/model.rb, line 175 def type output = modalities.output return :embedding if output.include?('embeddings') return :moderation if output.include?('moderation') return :image if output.include?('image') return :audio if output.include?('audio') return :video if output.include?('video') return :rerank if output.include?('rerank') :chat end
Returns the model’s primary function, inferred from its output modalities: :chat, :embedding, :moderation, :image, :audio, :video, or :rerank.
Source
# File lib/ruby_llm/model.rb, line 109 def unlisted? !unlisted_at.nil? end
Returns whether the configured provider has stopped listing the model. An unlisted model is kept only because application records still reference it, and it may already be failing at the provider.
model.unlisted? # => false