class RubyLLM::Model::PricingTier
A PricingTier holds the prices a model charges within one billing tier, standard or batch. Each price is in USD per one million tokens. Prices missing from the registry read as nil. A zero price means the usage is free.
Instances come from PricingCategory#standard and PricingCategory#batch:
model = RubyLLM.models.find "claude-sonnet-4-6" tier = model.pricing.text_tokens.standard tier.input_per_million # => 3 tier.output_per_million # => 15
Constants
- ATTRIBUTES
-
The names of the price readers a tier responds to.
Public Instance Methods
# File lib/ruby_llm/model/pricing_tier.rb, line 50
Returns the USD price per million input tokens read from the provider’s prompt cache, or nil if the price is missing.
# File lib/ruby_llm/model/pricing_tier.rb, line 56
Returns the USD price per million input tokens written to the provider’s prompt cache, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_tier.rb, line 38
Returns the USD price per million input tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_tier.rb, line 44
Returns the USD price per million output tokens, or nil if the price is missing.
# File lib/ruby_llm/model/pricing_tier.rb, line 67 ATTRIBUTES.each do |attribute| define_method(attribute) do @values[attribute] end end
Returns the USD price per million reasoning output tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_tier.rb, line 79 def to_h @values.dup end
Returns a new Hash of the tier’s prices with Symbol keys. Missing prices are omitted.
tier.to_h # => {input_per_million: 3, output_per_million: 15, ...}