class RubyLLM::Model::PricingCategory
A PricingCategory holds the standard and batch pricing tiers for one kind of model usage, such as text tokens or images. Model#pricing returns a Pricing collection whose categories are PricingCategory instances. Prices are in USD per million tokens.
model = RubyLLM.models.find "claude-sonnet-4-6" category = model.pricing.text_tokens category.input # => 3 category.output # => 15
Constants
- TIERS
-
The billing tiers a category may define.
Attributes
The batch-tier PricingTier, or nil when the model has no batch pricing for this category.
The standard-tier PricingTier, or nil when the model has no standard pricing for this category.
Public Instance Methods
Source
# File lib/ruby_llm/model/pricing_category.rb, line 46 def cache_read_input standard&.cache_read_input_per_million end
Returns the standard-tier cache read price in USD per million tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_category.rb, line 52 def cache_write_input standard&.cache_write_input_per_million end
Returns the standard-tier cache write price in USD per million tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_category.rb, line 34 def input standard&.input_per_million end
Returns the standard-tier input price in USD per million tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_category.rb, line 40 def output standard&.output_per_million end
Returns the standard-tier output price in USD per million tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_category.rb, line 58 def reasoning_output standard&.reasoning_output_per_million end
Returns the standard-tier reasoning output price in USD per million tokens, or nil if the price is missing.
Source
# File lib/ruby_llm/model/pricing_category.rb, line 64 def to_h result = {} result[:standard] = standard.to_h if standard result[:batch] = batch.to_h if batch result end
Returns a Hash with :standard and :batch tier hashes, omitting absent tiers.