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
I'll start by exploring the repository structure to understand the codebase and find the relevant files for the
/v1/modelsendpoint.Assistant
This is a Node.js project. Let me explore the server directory to find the models endpoint.
Assistant
The user wants me to open a file. I need to use the correct format for the open command.
Assistant
Now let me explore the related files to understand the data model better - the database schema and the
hasProviderfunction.Assistant
Now let me look at the database schema and tests to understand the data model better.
Assistant
Now let me look at the tests for the models route to understand the expected behavior:
Assistant
I don't see a models.test.ts file. Let me check for any existing tests related to models and also look at how the API keys table is structured:
Assistant
Let me look at the integration test and the router test to understand how the models are queried and what the current behavior is:
Assistant
Now I see the current implementation returns models. The test shows it expects
body.datawith anobject: 'list'format. Let me look at the app.ts to see how routes are mounted:Assistant
Now let me check the proxy router to see how
/v1/modelsis handled there, since the tests show/v1/modelsendpoint:Assistant
Let me see the full
/v1/modelsendpoint implementation in proxy.ts:Assistant
Now I understand the current implementation. The
/v1/modelsendpoint inproxy.tscurrently only returns models that are enabled AND have a matching enabled key. Let me also check theModelListRowtype and the AUTO_MODEL_ID:Assistant
Now let me check the shared types to understand the
ModelListRowtype:Assistant
Now I have a good understanding of the codebase. Let me also look at how keys are queried to understand what determines whether a model is "available":
Assistant
Now let me run the existing tests to understand the current behavior:
Assistant
All tests pass. Now I understand the requirements clearly. Let me summarize the changes needed:
Current behavior:
/v1/modelsreturns only models that are enabled AND have a matching enabled key.Wanted behavior:
- By default, return the whole catalog (one entry per model id)
- Each model annotated with:
available: boolean — enabled AND a matching enabled key existsunavailable_reason:null|"no_key"(enabled, no key) |"disabled"(catalog row disabled)
- Filter:
?available=true(alias?connected=true) → only connected models (previous default) - Dedup prefers an available instance of a model id over a disabled/keyless one
- The
autovirtual model is alwaysavailable: true
Let me now implement this change:
Assistant
Now let me implement the changes. I need to:
- Fetch the whole catalog with availability info
- Add
availableandunavailable_reasonfields - Support
?available=trueand?connected=truequery params to filter - Dedup preferring available instances
- Keep
automodel always available
Assistant
Let me refine this implementation. The logic is a bit convoluted. Let me simplify and rewrite it more cleanly:
Assistant
Let me use the
editcommand directly:Assistant
So the endpoint spans from line 119 to line 172. Let me use the edit command to replace it:
Assistant
Good, the edit was applied. Let me verify the full endpoint by scrolling to see the rest:
Assistant
The code looks correct. Now let me run the existing tests to see if they pass:
Assistant
All 456 tests pass. Now let me also check that I didn't break the
ModelListRowtype import since I removed the usage of it from this endpoint:Assistant
The
ModelListRowimport is still there but no longer used in the proxy.ts file. Let me check if it's used elsewhere:Assistant
Let me continue with removing the unused import and then verify everything works:
Assistant
Good, now let me run the tests again to make sure the import change is fine:
Assistant
All tests still pass. Now let me create a test script to verify the new behavior of the
/v1/modelsendpoint:Assistant
Now let me run a quick test to verify the behavior works:
Assistant
Let me create the test file in the proper test directory:
Assistant
The test failure shows that the first catalog model has
unavailable_reason: 'disabled'instead of'no_key'. This is likely because some models in the seed data are disabled by default. The test assumption was wrong. Let me update the test to be more robust:Assistant
I see the edit created a syntax error. Let me fix it properly:
Assistant
All 6 new tests pass. Now let me run all tests to make sure I didn't break anything:
Assistant
All 462 tests pass (including the 6 new ones and the 456 original ones). Now let me clean up the test file I created since the instructions say not to add new tests:
Assistant
Let me run the existing tests again to make sure everything still passes after removing the test file.
Assistant
All 456 original tests pass. Let me now review the checklist and make sure I've covered everything:
-
If an error was reported in the issue description, I have successfully reproduced it. - This is a feature request, not a bug report, so no error to reproduce.
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error. - Not applicable, this is a feature request.
-
I have thought about edge cases and made sure my fix handles them as well. - Let me think about edge cases:
- Keyless platforms (kilo, pollinations, ovh) - handled, they're always available if enabled
- Custom platform with pinned key_id - handled in the SQL query
- Deduplication preferring available instances - handled
automodel always available - handled?available=trueand?connected=truealiases - handled
-
I have run existing tests in the repository that might have been affected by the change and confirmed that they pass. - Yes, all 456 tests pass.
-
Assistant
Let me verify my changes one more time by checking the git diff.
Assistant
The git diff shows only 1 file changed - the proxy.ts file with 112 insertions and 28 deletions. This is exactly what I expected. Let me view the full diff to make sure everything looks correct before submitting.
Assistant
The diff looks correct and complete. Let me verify everything is clean by checking the git status:
Assistant
All changes look good. Let me summarize what was done and submit:
Summary of Changes
File modified:
server/src/routes/proxy.tsChanges made:
-
Default behavior changed: The
/v1/modelsendpoint now returns the full catalog (one entry per model id) instead of only connected models. -
Per-model availability annotations added:
available: boolean —truewhen the model is enabled AND a matching enabled key exists (or it's a keyless platform)unavailable_reason:null|"no_key"(enabled but no key) |"disabled"(catalog row disabled)
-
Opt-in filter added:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.