models.dev breadth registry loader.
Three-tier cache hierarchy mirroring hermes-agent/agent/models_dev.py:
Normalizes models.dev's per-provider tree into ModelEntry maps with :model/source :models-dev so the registry merge layer can compare against live /models fetches and the bundled snapshot uniformly.
models.dev breadth registry loader.
Three-tier cache hierarchy mirroring hermes-agent/agent/models_dev.py:
1. In-memory atom (1h TTL by default)
2. Disk cache at ~/.clojure-llm-sdk/models-dev-cache.json (1h by mtime)
3. Network fetch from https://models.dev/api.json
4. Stale disk cache fallback (network failed, disk exists but old)
5. Bundled snapshot at resources/models-dev-snapshot.json (last resort,
ships with the SDK so offline use works)
Normalizes models.dev's per-provider tree into ModelEntry maps with
:model/source :models-dev so the registry merge layer can compare
against live /models fetches and the bundled snapshot uniformly.models.dev API endpoint. Tests may rebind.
models.dev API endpoint. Tests may rebind.
Directory holding the on-disk models.dev cache. Tests may rebind.
Directory holding the on-disk models.dev cache. Tests may rebind.
Cache freshness threshold for in-mem + disk tiers.
Cache freshness threshold for in-mem + disk tiers.
(fetch-all)(fetch-all {:keys [force-refresh?]})Return {:data tree :fetched-at-ms long :source keyword}, walking the cache hierarchy: fresh in-mem → fresh disk → network → stale disk → bundled snapshot. Returns nil only if every tier fails (no network, no disk cache, no bundled snapshot).
Return {:data tree :fetched-at-ms long :source keyword}, walking the
cache hierarchy: fresh in-mem → fresh disk → network → stale disk →
bundled snapshot. Returns nil only if every tier fails (no network,
no disk cache, no bundled snapshot).(known-providers)Return the set of SDK provider keywords for which models.dev has data, intersected with the current cache tier.
Return the set of SDK provider keywords for which models.dev has data, intersected with the current cache tier.
(list-models provider-id)Return normalized ModelEntry maps for every model models.dev knows under our SDK provider keyword. Empty vector when the provider has no mapping or the registry is empty.
Return normalized ModelEntry maps for every model models.dev knows under our SDK provider keyword. Empty vector when the provider has no mapping or the registry is empty.
(lookup provider-id model-id)Look up (provider, model) and return a normalized ModelEntry tagged :model/source :models-dev. Returns nil when the provider has no mapping or models.dev doesn't know the model.
Look up (provider, model) and return a normalized ModelEntry tagged :model/source :models-dev. Returns nil when the provider has no mapping or models.dev doesn't know the model.
(normalize-entry provider-keyword model-id raw-entry ts)Convert a models.dev model entry into our canonical ModelEntry. The returned entry's :model/provider is the SDK provider keyword we were queried with, NOT the models.dev provider id — that way callers who look up by (:codex "gpt-5") get :codex back, not :openai.
Convert a models.dev model entry into our canonical ModelEntry. The returned entry's :model/provider is the SDK provider keyword we were queried with, NOT the models.dev provider id — that way callers who look up by (:codex "gpt-5") get :codex back, not :openai.
Map our SDK provider keywords to models.dev's provider ids. :codex / :codex-backend point at OpenAI's catalog (their wire endpoint serves the same model set). :gemini-native uses 'google', :vertex-gemini uses 'google-vertex' (separate catalog including Anthropic-on-Vertex).
Map our SDK provider keywords to models.dev's provider ids. :codex / :codex-backend point at OpenAI's catalog (their wire endpoint serves the same model set). :gemini-native uses 'google', :vertex-gemini uses 'google-vertex' (separate catalog including Anthropic-on-Vertex).
(refresh!)Force a network fetch, bypassing in-mem and disk caches. Returns the new cache map, or nil if the network call failed.
Force a network fetch, bypassing in-mem and disk caches. Returns the new cache map, or nil if the network call failed.
(reset-cache!)Clear the in-memory cache. Tests use this to isolate runs.
Clear the in-memory cache. Tests use this to isolate runs.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |