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
| List | How |
|---|---|
| Provider list | provider.json providers plus the models.dev index, names and status only |
| Model list | Queried for one provider (_browse_models_with_error): the official source when credentialed, models.dev filling gaps or standing in, else empty. A short memory cache keeps the result |
| Model only the official list names | Takes what it accepts (images, files, tools) from the listed model its id extends, grok-4.7-build-fast from grok-4.7, since a row with no word on it is text only. Price, context and name are never carried over |
| models.dev catalogue | In memory and on disk, fresh for an hour. The disk copy's age is its file's, since every command is a new process |
| Source shape | Fetcher |
|---|---|
Standard /v1/models | listing/fetchers/openai_compat.py |
| Anthropic, per-model capabilities | adapters/anthropic/list_models.py |
| Vendor-specific | google (query key), amazon_bedrock (SigV4), 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.
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. |
| Refresh | Re-browses enabled models and overwrites their specs |
| Manual model | Same list, source: "manual" |
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 |
runtime/harnesses/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':'gpt6 sol'; did you mean openai: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.
- 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. cost, multimodalinput,headersandcompattravel 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.