Module: LlmCostTracker::Pricing::Lookup

Defined in:
lib/llm_cost_tracker/pricing/lookup.rb

Defined Under Namespace

Classes: Match

Constant Summary collapse

MUTEX =
Monitor.new

Class Method Summary collapse

Class Method Details

.call(provider:, model:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/llm_cost_tracker/pricing/lookup.rb', line 12

def call(provider:, model:)
  provider_name = provider.to_s
  model_name = model.to_s
  provider_model = provider_name.empty? ? model_name : "#{provider_name}/#{model_name}"
  normalized_model = normalize_model_name(model_name)
  current = current_price_tables

  explain_table(current.fetch(:pricing_overrides), :pricing_overrides, provider_model, model_name,
                normalized_model) ||
    explain_table(current.fetch(:file_prices), :prices_file, provider_model, model_name, normalized_model) ||
    explain_table(Pricing::PRICES, :bundled, provider_model, model_name, normalized_model)
end