Model catalog
- Browse: official list and models.dev, memory only
- enable
- config.json: full spec rows with provider.json fields
- ENABLED_MODELS: get_model, chat picker, agents, failover
Selectable in chat equals enabled equals resolvable: there is one list. No big files, nothing stale, and the package directory stays read-only.
Who writes what
| Author | Location | Content |
|---|---|---|
| Humans, in git | providers/adapters/<p>/provider.json, plus <p>.py for dedicated protocols | endpoints, thinking, cache, overrides |
| The program | config.json → providers.<p>.models | enabled specs, keys, user state |
| Network | models.dev, official /v1/models | browsing only |
Providers with no directory work through models.dev. catalog/enabled_models.py is the registry, settings/storage.py persists config, settings/thinking_spec.py holds thinking, models/listing/ is what interfaces read. Nothing else is named a catalog.
provider.json
Every field optional. If a machine can obtain a field, a human does not write it, so there is no model list.
| Field | Purpose | Default |
|---|---|---|
endpoints | named api and base_url groups | models.dev base_url, OpenAI-compatible |
thinking | wire_format, effort maps, per-model levels: Thinking effort | low, medium, high |
cache | prompt caching | none |
model_overrides | per-model headers, compat, endpoint, key_prefix; folded into the spec at enable time | none |
Directories use underscores (amazon_bedrock/); id keeps hyphens. One service with two protocols is two endpoints of one provider.
Browse
Provider list: provider.json providers plus the models.dev index, with names and status only. Model list: queried for one provider, by _browse_models_with_error: the official source when credentialed, models.dev filling gaps or standing in, else empty.
A model the official list names and models.dev does not takes what it accepts (images, files, tools) from the listed model its id extends, grok-4.7-build-fast from grok-4.7: an official list seldom says what a model accepts, and a row with no word on it is text only. Price, context and name are never carried over.
| Source shape | Fetcher |
|---|---|
Standard /v1/models | listing/fetchers/openai_compat.py |
| Anthropic, per-model capabilities | adapters/anthropic/list_models.py |
| Account-level private | adapters/openai_codex/list_models.py, xai_subscription/list_models.py |
| Vendor-specific | google (query key), amazon_bedrock (SigV4), github_copilot (session bearer), deepseek (ids only, enriched) |
A provider that departs from standard ships list_models.py exposing fetch(provider_id, timeout); _load_fetcher imports it by directory, no central edit. Success: list[dict] with id and name. Failure: {"error": …}. fetch_and_normalize is the one normalisation point.
Ordinary results use a short memory cache. Subscription catalogues also keep an atomic last-known-good copy: a failed request can show stale rows, but only a non-empty official catalogue can retire models.
The models.dev catalogue is kept in memory and on disk, fresh for an hour. The disk copy's age is its file's: every command is a new process, and one that took the file for stale whatever its age downloaded the catalogue again and waited about three seconds for it on its way out.
Enable, disable, refresh
| Action | Effect |
|---|---|
Enable (toggle_model) | Browse row, overrides, endpoint api and base_url, derived thinking levels go in providers.<p>.models; the registry reloads |
| Disable | Deletes the row; a manual row stays with enabled: false. Subscription providers record the id in disabled_models. |
| Refresh | Re-browses enabled models and overwrites their specs |
| Manual model | Same list, source: "manual" |
| Subscription catalogue | After login, worker start when stale, every 6 h, manual Refresh: new ids enabled, changes refreshed, removed retired, disables kept. A change broadcasts provider_models_changed; web and desktop re-read, reconnecting clients too. |
Use
| Reader | Source |
|---|---|
| Backend | ENABLED_MODELS, key <prefix>/<id>, through get_model, get_providers, get_models; aliases on a miss |
GET /api/providers/list | Provider list |
GET /api/providers/{name}/models | That provider's cached browse and enabled flags; POST …/fetch-models queries now |
GET /api/models/enabled | Chat picker: ENABLED_MODELS as is |
interfaces/server/thinking_effort.py | Levels from enabled rows |
A failover or agent reference to a non-enabled model is a configuration error pointing at Settings. Old sessions keep their history but cannot continue on a deleted model.
An unknown id is refused with the nearest ones (catalog/suggestions.py): "Unknown model 'openai-codex':'gpt6 sol'; did you mean openai-codex:gpt-6.1-sol, …?". Names compare by words: display-name word 4, id word 3; a version or provider id counts only beside those. Follows magpie (yetone/magpie, MIT).
Invariants
- The only persisted model data is enabled specs in config, plus the subscription last-known-good copy.
- Ordinary browsing is never written to a file.
- Human data in git, program data in user config.
provider.jsonhas only what machines cannot obtain.openprogram.models.providersnever importsopenprogram.interfaces.server; the listing imports providers, never the reverse.<prefix>/<id>, alias fallback andkey_prefixare preserved; the registry stays one mutable dict.- One each:
fetch_and_normalize(row shape),_upsert_spec_rowwith_normalize_spec_row(into config),_build_model_from_row(intoModel).
What a change must preserve
- A config row resolves through
get_modelto the sameModelfor every provider. google-gemini-cli/*andgemini-subscription/*are distinct keys; rows carry their own.cost, multimodalinput,headers(copilot) andcompattravel in the spec.- Multi-wire providers need one exec per
(api, base_url, headers, compat). test_provider_wire_invariants.pyandtest_model_fetch_routing.pystay green.