/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 understand the current implementation. Let me check the README's mention of
/v1/modelsand the models table schema: - Assistant
Now I'll implement the change. First, update the shared type:
- Assistant
Now the endpoint itself:
- Assistant
Now add tests. The existing test file covers
/v1/models; I'll add coverage for the new behavior: - Assistant
All 8 tests pass. Let me verify the conditional branches in my tests actually exercise assertions against the seeded catalog (rather than silently skipping):
- Assistant
All 459 tests pass. Let me check if there's API documentation to update:
- Assistant
No separate API docs. The README feature line still holds, but since the default behavior of
/v1/modelschanges (full catalog instead of connected-only), a brief note is warranted: - Assistant
Final review of the diff:
- Assistant
Done.
GET /v1/modelsnow returns the full catalog with per-model availability annotations and an opt-in connected-only filter.Changes:
server/src/routes/proxy.ts:119— The endpoint's SQL now scans the wholemodelstable (noenabled/keyWHEREclause), computingavailableper row asenabled = 1 AND EXISTS(matching enabled key). The dedup window orders byavailable DESCfirst, so an available instance of a model id always wins over a disabled/keyless one.unavailable_reasonis derived in SQL:NULLwhen available,'disabled'when the catalog row is off,'no_key'otherwise.?available=trueor (also accepting ) restores the old connected-only behavior via a bound parameter. The virtual entry is hardcoded .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.