/v1/models: return the full catalog with per-model availability + opt-in filter Split…
- User
/v1/models: return the full catalog with per-model availability + opt-in filter Split out from #242.
Current: `GET /v1/models` returns only models that are connected right now (enabled AND an enabled key can serve them).
Wanted: by default return the whole catalog (one entry per model id), each annotated with whether it's usable, plus an opt-in filter to get just the connected ones.
Per-model annotation:
- `available`: boolean — enabled AND a matching enabled key exists.
- `unavailable_reason`: `null` | `"no_key"` (enabled, no key) | `"disabled"` (catalog row disabled).
Filter:
- `?available=true` (alias `?connected=true`) → only connected models (the previous default behavior).
Notes:
- The extra fields are additive — OpenAI-compatible clients ignore unknown fields.
- Dedup prefers an available instance of a model id over a disabled/keyless one.
- The `auto` virtual model is always `available: true`.
Interface
No new interfaces are introduced.
- Assistant
Now I'll implement the change in
proxy.ts: - Assistant
Let me verify the schema columns and check the openai-compat provider (which also referenced /v1/models):
- Assistant
Now let me add tests. First check what seeded groq models exist:
- Assistant
All new tests pass. Now run typecheck and the full server suite:
- Assistant
One more spot — the error message at
proxy.ts:661points clients to/v1/models"for the available list", which now returns the full catalog by default: - Assistant
Done. All 462 tests pass and
tscis clean.Changes
server/src/routes/proxy.ts— reworkedGET /v1/models:- The SQL no longer filters to
enabled = 1+ key-exists; instead it computesenabledand ahas_keyEXISTS flag per row, and the dedup window now orders by(enabled * has_key) DESCfirst — so an available instance of a model id always wins over a disabled/keyless duplicate, then falls back to the originalintelligence_rank, idordering. - Each entry gains additive fields:
available(enabled AND matching enabled key) andunavailable_reason(null|"no_key"when enabled but keyless |"disabled"when the catalog row is off — disabled takes precedence).
- The SQL no longer filters to
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.