Class: Multiwoven::Integrations::Core::OpenRouterCatalog
- Inherits:
-
Object
- Object
- Multiwoven::Integrations::Core::OpenRouterCatalog
- Defined in:
- lib/multiwoven/integrations/core/open_router_catalog.rb
Overview
Live model metadata from OpenRouter's public /models endpoint, so a connector need not ship prices that go stale. Providers opt in with an openrouter_slug; embeddings and partner-hosted models stay curated in models.json.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- MODELS_URL =
"https://openrouter.ai/api/v1/models"- CACHE_KEY =
"multiwoven_open_router_catalog_v1"- CACHE_TTL =
86_400- REQUEST_CONFIG =
{ timeout: 10, open_timeout: 5 }.freeze
- PER_MILLION =
1_000_000
Class Method Summary collapse
-
.fetch ⇒ Object
Two layers: a host cache may be absent or a null store, so the memo is what prevents a re-fetch of half a megabyte per request.
- .reset! ⇒ Object
Class Method Details
.fetch ⇒ Object
Two layers: a host cache may be absent or a null store, so the memo is what prevents a re-fetch of half a megabyte per request.
26 27 28 29 30 31 32 |
# File 'lib/multiwoven/integrations/core/open_router_catalog.rb', line 26 def fetch return @memo if live_memo? result = to_result(cached_payload) @memo = result if result.source == "live" result end |
.reset! ⇒ Object
34 35 36 37 38 39 |
# File 'lib/multiwoven/integrations/core/open_router_catalog.rb', line 34 def reset! @memo = nil cache&.delete(CACHE_KEY) rescue StandardError => e log_cache_failure("delete", e) end |