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`.
Interface
No new interfaces are introduced.
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 exploring the repository structure to understand what we'reworking with.
Assistant
Now let's look at where
/v1/modelsis registered:Assistant
Now let's look at the proxy route to understand
/v1/models:Assistant
Let me look at the test for the proxy and understand the existing test patterns:
Assistant
Now let me look at the existing test files to understand how to add tests:
Assistant
Now let's look at the proxy.ts file to understand the relevant context:
Assistant
Now let me look at the schema of the models table to understand
key_id:Assistant
Now let me look at the rest of the migrations to understand
key_id:Assistant
Now I have a good understanding. Let me think through the requirements:
Goal: Change
/v1/models(proxy.ts) to:- By default: return the entire catalog (one entry per model id) with per-model availability annotation
- With
?available=trueor?connected=true: filter to only connected/available models (previous default behavior)
Each model entry needs:
available: boolean (enabled AND a matching enabled key exists)unavailable_reason:null|"no_key"|"disabled"
Notes:
- Dedup prefers an available instance of a model id over a disabled/keyless one
autovirtual model is alwaysavailable: true
Let me look at how existing tests verify the catalog:
Assistant
Let me also check how queries are done elsewhere for context:
Assistant
Now let me look at what client uses /v1/models and understand the exact expected output:
Assistant
Now let me check the previous tests to see if any are passing currently:
Assistant
All tests pass. Now let me think about the implementation. Let me look at the current implementation and the existing test carefully:
Assistant
Now let me look at the keys table interactions to understand custom providers:
Assistant
Good. Now I understand the exact same conditions. Let me now write a small reproduction test first to make sure I understand the current behavior:
Assistant
Now I confirmed the current behavior: only
autois returned without keys. Let me remove the temporary file and design the fix:Assistant
Now let me design and implement the change. Let me view the exact existing proxy.ts code for
/v1/models:Assistant
Now I'll implement the new logic. Let me start by modifying proxy.ts:
Assistant
I'll need to extend the ModelListRow or create a new one with the extra fields. Let me think about whether I should modify the existing interface or create a new one. Since the interface is used in this single place, I'll just inline the new shape rather than change the shared interface (less surface area for changes).
Actually,let me check if ModelListRow is used anywhere else:
Assistant
Now I'll implement the fix. Let me modify the
/v1/modelsendpoint in proxy.ts:Assistant
Let me now write the change:
Assistant
Now I'll edit proxy.ts to implement the change:
Assistant
Now let me apply the replacement:
Assistant
Let me find the exact line numbers:
Assistant
Let me find the precise ending line of the models endpoint. Looking at line 174-175, that's the closing brace of the route, followed by an empty line, then line 176 should be
const MAX_RETRIES = 20;.Wait, looking at the current output:
- Line 121: proxyRouter.get('/models', ...
- ...
- Line 174:
});(this looks like the closing of the response.json)
Actually let me re-read. I see:
- Line 152-166: res.json({...})
- Line 167: });
- Line 168:
- Line 169:
Let me check again.
Assistant
Now let me replace lines 119-172 with the new content:
Assistant
Now let me use the
editcommand to replace lines 119-172 with the new content:Assistant
Let me see the rest:
Assistant
The replacement looks good. Now let me run the existing tests to make sure I haven't broken anything:
Assistant
Now let me run the entire test suite:
Assistant
All tests pass. Now let me create a verification script to test the new behavior:
Assistant
All the new tests pass. Now let me verify more edge cases:
Assistant
Let me look at the API structure to understand the test failure:
Assistant
The response is the array directly, not
{keys: [...]}. Let me also check the disable endpoint:Assistant
OK so the disable endpoint is PATCH
/:idwithenabled: false. Let me fix the test and re-run:Assistant
All edge cases work correctly. Now let me also test the custom provider with
key_id:Assistant
Let me also verify with custom provider models:
Assistant
All 8 tests pass! Now let me run the full test suite to make sure I haven't broken anything:
Assistant
All 464 tests pass. Now let me clean up the temporary test file:
Assistant
Let me also verify the tests work without the temporary file:
Assistant
Now let me review my final implementation:
Assistant
Let me also verify the existing tests in
proxy-auto-model.test.tspass:Assistant
All existing tests pass. Let me also check that no other places reference the model structure that might be affected:
Assistant
Let me also check the rest of the test files for any I might have missed that test /v1/models:
Assistant
Let me also check the client to ensure it doesn't rely on specific properties that I've changed:
Assistant
The client doesn't depend on these properties. Let me look at the final diff of my changes:
Assistant
The diff looks clean and minimal. Let me also check the git status to ensure I haven't left any stray files:
Assistant
Only
server/src/routes/proxy.tsis modified. Let me also run the full test suite one more time to be 100% sure:Assistant
All 456 tests pass. Now let me think about whether there are any other edge cases I should consider:
Assistant
All 8 edge case tests pass! Now let me clean up the temporary file:
Assistant
Only
proxy.tsis modified. Let me run the full test suite once more to confirm everything still works:Assistant
All 456 tests pass. Let me also do a final check on the complete diff:
Assistant
The diff is clean and focused. Let me think about whether the implementation handles all the requirements from the issue:
Requirements:
Assistant
No tests rely on the specific shape of the response other than the ones I checked. Let me also do a final review by reading the current proxy.ts code one more time:
Assistant
The implementation is complete. Let me also verify that the TypeScript code compiles correctly:
Assistant
TypeScript compiles cleanly. Let me run the full test suite one final time:
Assistant
All 456 tests pass and TypeScript compiles cleanly.
Let me think about the checklist once more:
Checklist (from the issue):
-
If an error was reported in the issue description, I have successfully reproduced it. — I confirmed the previous behavior (only connected models) by running the existing test, then verified the new behavior (full catalog with annotations) returns correctly.
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error. — Verified through manual test scripts that:
- Default request returns full catalog with and on each entry
-
Assistant
All imports are still in use. The
ModelListRowis still used in the type cast(ModelListRow & { priority: number })[]. The implementation is complete and clean.Now let me submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.