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
I'll start by exploring the repository structure to understand the codebase.
Assistant
This is a Node.js project. Let me explore the server directory and look for the
/v1/modelsendpoint.Assistant
Let me look at the models route file first.
Assistant
Now let me understand the broader context. Let me look at the shared types, the DB schema, and how the proxy/router determines "connected" models.
Assistant
Now let me look at the DB schema to understand the models table structure, and how
automodel works.Assistant
Now let me look at how the proxy/router determines connected models and the
automodel. Let me look at the router and proxy.Assistant
Let me look at how the proxy route handles the
automodel and themodelslisting. Let me check the app.ts to understand routing structure and where/v1/modelsis mounted.Assistant
Now I see
/api/modelsis the dashboard route. The issue mentions/v1/modelswhich is OpenAI-compatible. Let me check the proxy router.Assistant
I found the key endpoint:
proxyRouter.get('/models', ...)inproxy.ts. This is the/v1/modelsendpoint described in the issue. Let me look at the existing tests related to this endpoint and check theModelListRowtype usage.Assistant
Now I have a clear picture. Let me look at the
ModelListRowtype usage and check how the keys route/platforms work.Assistant
Now let me understand how keyless providers work in routing, since that affects the "matching enabled key" logic.
Assistant
Let me check the existing tests for the
/v1/modelsendpoint to understand expected behavior and the test helpers.Assistant
Let me run the existing
/v1/modelstests to confirm the environment works before making changes.Assistant
Tests pass. Now let me write a reproduction script to confirm the current behavior — that
/v1/modelsonly returns connected models.Assistant
The current behavior is confirmed: only connected models returned, no
available/unavailable_reasonfields. Let me check the catalog size and groq model count to understand the dedup behavior.Assistant
Now I understand the catalog well — there are 110 rows, with duplicate
model_ids across platforms (e.g.,codestral-lateston both mistral and openrouter), and some disabled models. Let me look at the exact lines of the endpoint to edit.Assistant
Now let me replace the endpoint with the new implementation.
Assistant
Now let me remove the now-unused
ModelListRowimport.Assistant
Now let me run the reproduction test to confirm the new behavior works.
Assistant
The new behavior works. Let me write a more thorough test to verify the dedup preference logic and the equivalence with the previous behavior.
Assistant
Let me see the console output for the codestral entry which failed.
Assistant
The dedup is picking the mistral instance (no_key) over the openrouter instance (available). Let me investigate which platforms hold
codestral-latest.Assistant
codestral-latestis onmistralandllm7, not openrouter. My test assumption was wrong. Let me fix the test to usellm7(which needs a key) to verify dedup picks the available instance.Assistant
All edge cases pass. Now let me run the existing tests that touch the
/v1/modelsendpoint to ensure no regressions.Assistant
Existing tests pass. Now let me check if there's a TypeScript build step I should validate, and check the client to see if anything consumes the
/v1/modelsresponse shape (to be safe about the additive fields).Assistant
TypeScript compiles cleanly. Let me check the README for any
/v1/modelsdocumentation that should be updated.Assistant
Let me check the docs directory for any API docs referencing
/v1/models.Assistant
No docs to update. Let me run the full routes test suite to ensure no regressions.
Assistant
All route tests pass. Now let me clean up my temporary test files since the instructions say not to add new tests to the repository.
Assistant
Let me verify the
ModelListRowtype isn't used anywhere else now (it's in shared, could be used by client).Assistant
ModelListRowis now unused but I'll leave the shared type definition (it's an exported type, harmless, and removing it is out of scope). Let me run the broader server test suite to confirm nothing else broke.Assistant
All 456 tests pass. Let me review my final diff.
Assistant
The diff is clean. Let me view the final endpoint once more to confirm correctness.
Assistant
The implementation is complete and correct. Let me do a final full test run to confirm everything passes before submitting.
Assistant
All 456 tests pass. Let me verify the git status one final time to confirm only the intended file is changed and temp files are gone.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.