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
Let me explore the server directory which is likely where the /v1/models endpoint is implemented.
Assistant
Let me check the database structure and existing models:
Assistant
Let me check the tests folder for models:
Assistant
Let me find where the /v1/models endpoint is registered:
Assistant
Let me look at the model structure and the key_id field:
Assistant
Now let me look at the entire /v1/models endpoint code and surrounding context:
Assistant
Now let me look at the import section and look at how the AUTO_MODEL_ID is defined:
Assistant
Now let me look at the app.ts to understand the appstructure better:
Assistant
Now let me check existing tests to understand the test structure and how the current /v1/models test expects things:
Assistant
Now let me run the existing tests to understand if everything works:
Assistant
Let me write a script to test the current behavior:
Assistant
Let me insert the API key directly:
Assistant
Let me check the full test outputs more thoroughly. Now let me also explore the catalog-sync:
Assistant
Let me verify how my understanding of the current test works with current data:
Assistant
Let me check other relevant tests and the router service:
Assistant
The client uses
/v1/modelsonly via the proxy. Let me check if thereare client requests to/v1/models:Assistant
Now I have a good understanding. Let me make the changes to the proxy.ts file:
Assistant
Now I'll edit the proxy.ts to implement the changes:
Assistant
Now I'll make the change to the proxy.ts. Let me edit the
/v1/modelsroute:Assistant
Let me use a Node.js script to make the change:
Assistant
Now let me verify the change was applied correctly:
Assistant
Now let's test the change. Let me update the test script:
Assistant
Let me check the data more carefully to find an example of "no_key" reason:
Assistant
Let me run the existing tests to make sure they still pass:
Assistant
Now let me run the full test suite to make sure nothing is broken:
Assistant
Let me also test the custom provider case to make sure it works:
Assistant
Let me test the case where the custom key is disabled:
Assistant
Let me verify dedup behavior with duplicate model_ids:
Assistant
Let me also test a few more query string variants:
Assistant
Let me also verify auth still works correctly:
Assistant
Now let me check the rate limiting and other middleware don't break:
Assistant
Let me also do one more verification - confirming the request still works as expected with no keys at all (just the auto model):
Assistant
Let me also run TypeScript compilation check to make sure the types are correct:
Assistant
Let me verify the final diff:
Assistant
Let me clean up my temporary test file:
Assistant
Let me verify the change once more by running all tests:
Assistant
All 456 tests pass. Let me also check the final git status to see what changes are staged:
Assistant
Let me review the checklist before submitting:
Checklist Review:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅
- The issue describes the current behavior of
/v1/modelsreturning only connected models. I reproduced this with a test script that showed only 1 model (auto) returned when there are no keys, and only groq models returned when only a groq key was added.
- The issue describes the current behavior of
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.