ISSUE DESCRIPTION /v1/models: return the full catalog with per-model availability +…
- User
ISSUE DESCRIPTION
/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`.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
Assistant
Let me start by understanding the repository structure and then the specific issue. The issue is about modifying the
/v1/modelsendpoint to:- Return the full catalog with per-model availability annotations (by default)
- Add
availablefield (boolean) - Add
unavailable_reasonfield (null, "no_key", or "disabled") - Add
?available=true(or?connected=true) filter to return only connected models - The
autovirtual model is alwaysavailable: true - Dedup: prefer an available instance of a model id over disabled/keyless ones
Let me explore the repository first.
Assistant
Let me explore the server directory and find the relevant code for the
/v1/modelsendpoint.Assistant
Let me look at the server/src directory structure.
Assistant
Let me look at the relevant files - the models route, catalog-sync, and router
Assistant
Let me look at catalog-sync, router, and db index to understand more.
Assistant
Now let me look at the router and the db index to understand model availability:
Assistant
Let me look at the db/index.ts to understand the database structure
Assistant
Let me look at the git log to understand the current state:
Assistant
Let me look at the test files related to models to understand the current and expected behavior
Assistant
Let me look for any existing tests for the models route or references to the
/v1/modelsendpointAssistant
Let me look at the proxy-auto-model test to understand the current test expectations:
Assistant
Let me look at the app.ts to see how the routes are wired up
Assistant
Let me look at the proxy router to find the
/v1/modelsendpointAssistant
Let me look at the full
/v1/modelsimplementation in proxy.tsAssistant
Let me find where
AUTO_MODEL_IDandextractApiTokenare definedAssistant
Let me look at the shared types file:
Assistant
Let me find the shared types file:
Assistant
This is TypeScript. Let me look at the shared types:
Assistant
Now I have a clear understanding. Let me create a plan:
-
The
/v1/modelsendpoint inproxy.tscurrently only returns connected models (enabled + has key). Need to modify it to:- Return ALL catalog models by default
- Add
availableandunavailable_reasonfields per model - Support
?available=true/?connected=truefilter - Dedup preferring available instances
automodel alwaysavailable: true
-
Also update the
/api/modelsendpoint inroutes/models.tswith similar logic for the dashboard.
Let me first create a script to reproduce the current behavior and understand it
-
Assistant
Let me first run the existing tests to see the current
Assistant
Now I have a clear understanding of the codebase. Let me open the proxy.ts file to edit it
Assistant
That's odd. Let me try using the
opencommand directly:Assistant
Let me look at the test helper that seeds models:
Assistant
Let me look at how models are seeded in migrations for the test:
Assistant
Let me look at the seedModels function:
Assistant
Now I understand the full picture. Let me implement the changes to the
/v1/modelsendpoint. I'll edit the proxy.ts file:Assistant
Let me use the correct syntax with heredoc
Assistant
Good. Now let me run the existing tests to see if they pass
Assistant
All tests pass. Now let me also update the
/api/modelsendpoint inroutes/models.tswith the same availability annotations. Let me first look at the current endpoint and its tests:Assistant
Now let me update the
/api/modelsendpoint similarlyAssistant
Need to use heredoc for multi-line content
Assistant
Now let me run the tests to verify everything passes
Assistant
Let me run the full test suite to make sure nothing is broken
Assistant
All 456 tests pass. Let me also verify Type
Assistant
TypeScript compiles cleanly. Let me check for any tests related to
/api/modelsthat might be affected:Assistant
Let me search from the repo root
Assistant
Let me check the integration test that calls
/api/models:Assistant
Good. The integration test checks for
modelId,hasProvider, and length — all preserved. My changes are additive and don't break any existing tests.Let me now verify the final state of both files:
Assistant
Let me run the full test suite one final time to confirm everything passes
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.