Module: ActiveHarness::Pricing
- Defined in:
- lib/active_harness/pricing.rb,
lib/active_harness/pricing/models_dev.rb,
lib/active_harness/pricing/openrouter.rb
Overview
Pricing namespace — shared types and a facade over pricing source modules.
Sources (in priority order):
Pricing::OpenRouter — live data from OpenRouter API (all modalities, 72h cache)
Pricing::ModelsDev — live data from models.dev API (all providers, 72h cache)
Public facade delegates to ModelsDev (used as the general fallback):
Pricing.find("gpt-4o") → ModelPrice or nil
Pricing.all → Array<ModelPrice>
Pricing.providers.openai → Array<ModelPrice>
Pricing.update → refreshes ModelsDev cache
Defined Under Namespace
Modules: ModelsDev, OpenRouter Classes: ModelPrice, ProvidersProxy
Class Method Summary collapse
- .all ⇒ Object
- .find(model_id) ⇒ Object
- .for_provider(name) ⇒ Object
-
.preload! ⇒ Object
Eagerly load both pricing sources into memory.
- .provider_names ⇒ Object
- .providers ⇒ Object
Class Method Details
.all ⇒ Object
126 127 128 |
# File 'lib/active_harness/pricing.rb', line 126 def all ModelsDev.all end |
.find(model_id) ⇒ Object
122 123 124 |
# File 'lib/active_harness/pricing.rb', line 122 def find(model_id) ModelsDev.find(model_id) end |
.for_provider(name) ⇒ Object
134 135 136 |
# File 'lib/active_harness/pricing.rb', line 134 def for_provider(name) ModelsDev.for_provider(name) end |
.preload! ⇒ Object
Eagerly load both pricing sources into memory. Called at Rails startup via Railtie. Network failures are silently ignored.
117 118 119 120 |
# File 'lib/active_harness/pricing.rb', line 117 def preload! ModelsDev.preload! OpenRouter.preload! end |
.provider_names ⇒ Object
138 139 140 |
# File 'lib/active_harness/pricing.rb', line 138 def provider_names ModelsDev.provider_names end |