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 exploring the repository structure to understand the codebase and then find the relevant files for the
/v1/modelsendpoint.Assistant
Let me explore the server directory to understand the structure.
Assistant
Let me look at the app.ts and find the relevant route handler:
Assistant
Let me look at the proxy router which handles
/v1routes:Assistant
Let me look at the proxy.ts route file to find the
/v1/modelshandler.Assistant
The open command doesn't take FILE as a parameter - it takes the file path as the first positional argument. Let me check the documentation again.
Usage: open [OPTIONS] [FILE] [LINE_NUMBER]So it's
open server/src/routes/proxy.ts.Assistant
Let me search for the models endpoint handler in this file.
Assistant
Let me use grep to find the models endpoint in the proxy file.
Assistant
Let me look at the
/modelsendpoint handler around lines 119-170Assistant
Now let me understand the database schema. Let me check the migrations file and the db index:
Assistant
Let me check the migrations to understand the models table structure
Assistant
Now let me look at the services/router.ts to understand how models are currently determined to be
Assistant
Let me check the shared types for `ModelListRow
Assistant
Let me check the existing tests for the models endpoint and any tests related to it
Assistant
Let me check the integration full-flow test since it likely tests the /v1/models endpoint
Assistant
Now I have a comprehensive understanding of the code. Let me plan the changes:
-
server/src/routes/proxy.ts- Rewrite the/modelshandler to:- Return all catalog models by default (not just connected ones)
- Annotate each with
availableandunavailable_reason - Dedup preferring available instances over disabled/keyless ones
- Support
?available=true/?connected=truefilter - Keep
autoalwaysavailable: true
-
shared/types.ts- UpdateModelListRowto include the new fields
Let me first update the shared types, then the route
-
Assistant
Let me update the
ModelListRowtype to include the new fieldsAssistant
Let me try the edit command to modify the types file
Assistant
Let me use sed directly to make the change
Assistant
Let me use python to make the changes since sed can be tricky with multi
Assistant
Let me try with
Assistant
Now let me update the proxy.ts file to modify the
/modelshandler. Let me first see the exactAssistant
Now let me write the replacement using node
Assistant
Let me write the script to a temporary file and then
Assistant
Let me verify the changes were applied correctly.
Assistant
Let me see the rest of the handler
Assistant
Let me see a bit more:
Assistant
Good, the changes look correct. Let me also verify the shared types file:
Assistant
Now let me try to compile the TypeScript to check for any issues
Assistant
Let me check if there's a tsconfig for the server project and try building
Assistant
Let me try to compile the server project
Assistant
The code compiles cleanly. Let me now run the existing tests to make sure nothing breaks.
Assistant
Let me try running from the server directory
Assistant
All 456 tests pass. Let me also check if there are any other places that reference
ModelListRowto ensure they're compatibleAssistant
All 456 tests pass. Let me verify the full diff of changes
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.