class RubyLLM::Model::Pricing
A Pricing groups a modelβs prices by usage category: text tokens, images, audio tokens, and embeddings. Each category is a PricingCategory. Prices are in USD per million tokens. Instances come from Model#pricing.
model = RubyLLM.models.find "claude-sonnet-4-6" model.pricing.text_tokens.input # => 3 model.pricing.text_tokens.output # => 15
Constants
- CATEGORIES
-
The pricing categories a model may define.
Public Instance Methods
Source
# File lib/ruby_llm/model/pricing.rb, line 40 def audio_tokens category(:audio_tokens) end
Returns the PricingCategory for audio token prices, or an empty category if the model has none.
Source
# File lib/ruby_llm/model/pricing.rb, line 46 def embeddings category(:embeddings) end
Returns the PricingCategory for embedding prices, or an empty category if the model has none.
Source
# File lib/ruby_llm/model/pricing.rb, line 34 def images category(:images) end
Returns the PricingCategory for image generation prices, or an empty category if the model has none.
Source
# File lib/ruby_llm/model/pricing.rb, line 28 def text_tokens category(:text_tokens) end
Returns the PricingCategory for text token prices, or an empty category if the model has none.
Source
# File lib/ruby_llm/model/pricing.rb, line 52 def to_h @data.transform_values(&:to_h) end
Returns the pricing data as a nested Hash keyed by category. Categories without prices are omitted.