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 locate the relevant files for the
/v1/modelsendpoint.Assistant
It seems like this might be a Node.js project. Let me explore the directory structure more.
Assistant
Let me search for the models endpoint in the routes directory.
Assistant
The open command doesn't need quotes around the value. Let me fix that.
Assistant
Now let me look at the test files to understand the expected behavior better.
Assistant
Let me look for existing tests related to models.
Assistant
Let me check the integration test and also look for the provider index to understand
hasProvider.Assistant
Now let me look at the database schema and how the app routes are set up:
Assistant
Now I see the
/v1/modelsis handled by theproxyRouter. Let me look at it:Assistant
Let me look at the
/v1/modelsendpoint more closely:Assistant
Now let me understand the full current implementation. The current
/v1/modelsonly returns models that are enabled AND have a matching enabled key. According to the issue, I need to:- By default, return the whole catalog with each model annotated with
availableandunavailable_reason - Add an opt-in filter
?available=true(alias?connected=true) for just connected models (previous default behavior) - The
autovirtual model should always beavailable: true - Dedup prefers an available instance over a disabled/keyless one
Let me also look at the db schema and shared types:
- By default, return the whole catalog with each model annotated with
Assistant
Let me also check the shared types to understand the Platform type:
Assistant
Now let me look at the AUTO_MODEL_ID constant:
Assistant
Now let me check the existing tests for the
/v1/modelsendpoint:Assistant
Now I have a good understanding of the codebase. Let me also check what the database schema looks like for models:
Assistant
Now I have all the information I need. Let me plan the implementation:
Plan
- Modify
/v1/modelsendpoint inproxy.tsto:- By default, return the whole catalog (all unique model IDs from the
modelstable) - Annotate each model with
available(boolean) andunavailable_reason(null | "no_key" | "disabled") - Support
?available=true(alias?connected=true) query parameter to filter to only connected models (previous default behavior) - The
autovirtual model is alwaysavailable: true - Dedup prefers an available instance of a model id over a disabled/keyless one
- By default, return the whole catalog (all unique model IDs from the
Let me also check if there's a
key_idcolumn in the models table:- Modify
Assistant
Now I understand the full picture. Let me write the updated
/v1/modelsendpoint:Assistant
Now I'll create the updated implementation. The key changes are:
- Query the full catalog (all models, regardless of enabled/key status)
- For deduplication, prefer available instances (enabled AND has key) over disabled/keyless ones
- Annotate each model with
availableandunavailable_reason - Support
?available=true/?connected=truefilter to get only connected models - Keep the
autovirtual model always available
Assistant
Now let me see the exact line numbers to replace in the proxy.ts file:
Assistant
The replacement is lines 119-175. Let me apply the edit:
Assistant
Let me try the edit with the correct syntax:
Assistant
Now let me verify the changes:
Assistant
Good, the code looks correct. Let me also check that the rest of the file is intact:
Assistant
Now let me build the project and run the tests:
Assistant
Let me build the project first to check for TypeScript errors:
Assistant
I see the issue - the
MAX_RETRIESconstant was defined right after the old endpoint code and got lost. Let me check:Assistant
The
const MAX_RETRIES = 20;declaration got removed. Let me check the original file to see where it was:Assistant
I can see that
const MAX_RETRIES = 20;was removed. This is because when I did the split, I included lines up to 175 (which included the blank line but not theconst MAX_RETRIES = 20;line). Let me check the original line numbers:Assistant
I see - the original file had
const MAX_RETRIES = 20;at line 175, and my replacement ended at line 175 which replaced it. Let me fix this by adding the constant back:Assistant
I need to add
const MAX_RETRIES = 20;after the closing});of the/modelsendpoint and before the comment about echo-tolerant tool calls. Let me fix this:Assistant
Good, now let me build again:
Assistant
The build succeeded. Now let me run the relevant tests to make sure everything works:
Assistant
Tests are running. Let me wait for them to complete:
Assistant
All 456 tests pass. Now let me specifically run the auto-model tests that exercise the
/v1/modelsendpoint:Assistant
All tests pass. Now let me also run the integration tests:
Assistant
All tests pass. Now let me create a test script to verify the new functionality works as expected:
Assistant
The test failures are just in my temporary test script - some models in the catalog are disabled (like
gemini-2.5-pro), so they haveunavailable_reason: "disabled"instead of"no_key". This is actually correct behavior! The test assumptions were wrong.Let me fix my temporary test to handle this correctly:
Assistant
All my custom tests pass. Now let me clean up the temporary test file and run all the tests to make sure nothing is broken:
Assistant
All 456 tests pass. Let me verify the final state of the changes:
Assistant
Let me review the checklist items from the issue description:
-
If an error was reported in the issue description, I have successfully reproduced it.
- The issue doesn't report an error but describes a feature request to modify the
/v1/modelsendpoint behavior. I verified the current behavior by examining the existing code.
- The issue doesn't report an error but describes a feature request to modify the
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- Since this is a feature request (not a bug), I confirmed the fix works by:
-
Assistant
Let me try again with the correct command format.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.