Class: RubyLLM::Model::PricingCategory

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/model/pricing_category.rb

Overview

Represents pricing tiers for different usage categories (standard and batch)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ PricingCategory

Returns a new instance of PricingCategory.



9
10
11
12
# File 'lib/ruby_llm/model/pricing_category.rb', line 9

def initialize(data = {})
  @standard = PricingTier.new(data[:standard] || {}) unless empty_tier?(data[:standard])
  @batch = PricingTier.new(data[:batch] || {}) unless empty_tier?(data[:batch])
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



7
8
9
# File 'lib/ruby_llm/model/pricing_category.rb', line 7

def batch
  @batch
end

#standardObject (readonly)

Returns the value of attribute standard.



7
8
9
# File 'lib/ruby_llm/model/pricing_category.rb', line 7

def standard
  @standard
end

Instance Method Details

#[](key) ⇒ Object



37
38
39
# File 'lib/ruby_llm/model/pricing_category.rb', line 37

def [](key)
  key == :batch ? batch : standard
end

#cache_read_inputObject Also known as: cached_input



22
23
24
# File 'lib/ruby_llm/model/pricing_category.rb', line 22

def cache_read_input
  standard&.cache_read_input_per_million || standard&.cached_input_per_million
end

#cache_write_inputObject Also known as: cache_creation_input



26
27
28
# File 'lib/ruby_llm/model/pricing_category.rb', line 26

def cache_write_input
  standard&.cache_write_input_per_million || standard&.cache_creation_input_per_million
end

#inputObject



14
15
16
# File 'lib/ruby_llm/model/pricing_category.rb', line 14

def input
  standard&.input_per_million
end

#outputObject



18
19
20
# File 'lib/ruby_llm/model/pricing_category.rb', line 18

def output
  standard&.output_per_million
end

#reasoning_outputObject



30
31
32
# File 'lib/ruby_llm/model/pricing_category.rb', line 30

def reasoning_output
  standard&.reasoning_output_per_million
end

#to_hObject



41
42
43
44
45
46
# File 'lib/ruby_llm/model/pricing_category.rb', line 41

def to_h
  result = {}
  result[:standard] = standard.to_h if standard
  result[:batch] = batch.to_h if batch
  result
end