Class: Llm::UsageRecord
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Llm::UsageRecord
- Defined in:
- app/models/llm/usage_record.rb
Overview
One row per successful Llm::Client call: which provider/model actually served it, how many tokens it used, and what that cost at the time (using Llm::ProviderRegistry's pricing at the moment of the call, not whatever the registry says later — prices drift, history shouldn't).
Deliberately keyed by provider/model strings, not a credential_id — a credential can be reranked or removed, but its usage history shouldn't disappear with it.
Class Method Summary collapse
Class Method Details
.total_cost(scope = all) ⇒ Object
18 19 20 |
# File 'app/models/llm/usage_record.rb', line 18 def self.total_cost(scope = all) scope.sum(:cost_usd) end |