Module: RubyLLM::Contract::CostCalculator

Defined in:
lib/ruby_llm/contract/cost_calculator.rb

Class Method Summary collapse

Class Method Details

.calculate(model_name:, usage:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/ruby_llm/contract/cost_calculator.rb', line 6

def self.calculate(model_name:, usage:)
  return nil unless model_name && usage.is_a?(Hash)

  model_info = find_model(model_name)
  return nil unless model_info

  compute_cost(model_info, usage)
rescue StandardError
  nil
end