cache
Class info¶
🛈 DocStrings¶
In-process cache of the model lists providers return.
A provider's response is cached on disk by the HTTP layer (MODELS_CACHE_TTL), but
parsing it is the expensive part: models.dev lists about 10k models, a few hundred ms
to parse. The parsed, unfiltered list is kept here for the same time, per provider and
request headers (a different API key may see different models), so repeated discovery
costs only the filtering.
MODELS_CACHE_TTL
module-attribute
¶
Seconds a provider's model list is reused, on disk and in memory (24 hours).
clear_models_cache
¶
get_cached
¶
get_cached(name: str, provider: ModelProvider) -> list[ModelInfo] | None
The provider's parsed model list, if fetched within its models_cache_ttl.
Source code in src/tokonomics/model_discovery/cache.py
store
¶
store(name: str, provider: ModelProvider, models: list[ModelInfo]) -> None
Keep the provider's parsed model list (an empty one is not kept: a failed fetch).