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 the codebase.
Assistant
This is a JavaScript/Node.js project. Let me explore the structure more.
Assistant
Wait, this is the settings/admin models route. But the issue is about
GET /v1/models. Let me check the index.ts to understand routing.Assistant
Let me look at the shared types and the database schema to understand the models table.
Assistant
Let me look at the database schema for the models and api_keys tables.
Assistant
Let me check if there's a
key_idcolumn on models table.Assistant
Now let me look at the existing tests for the models route to understand the expected behavior.
Assistant
Let me look at the full-flow integration test and check how models are counted.
Assistant
That's the
/api/modelsadmin route, not/v1/models. So it's not affected.Now let me check if there are any other tests referencing
/v1/modelscounts.Assistant
Now let me view the exact lines of the current
/modelshandler to edit.Assistant
Now I'll rewrite the
/modelshandler to return the full catalog with availability annotations and an opt-in filter.Assistant
The
ModelListRowimport may now be unused. Let me check.Assistant
ModelListRowis no longer used in proxy.ts. Let me check if the build will fail on unused imports. TypeScript by default doesn't error on unused imports unlessnoUnusedLocalsis on. Let me check tsconfig.Assistant
noUnusedLocalsis not set so it won't error, but let me clean up the unused import anyway. Let me check ifChatMessageis still used.Assistant
The single quotes within the search string are causing issues. Let me use the heredoc syntax.
Assistant
Now let me build the server to check for TypeScript errors.
Assistant
Build succeeds. Now let me write a temporary reproduction/verification script to test the new behavior.
Assistant
Let me run the existing relevant tests first to make sure they pass.
Assistant
Existing tests pass. Now let me create a temporary verification script to test the new behavior thoroughly.
Assistant
All my temporary tests pass. Let me verify the dedup logic actually triggers by checking duplicate model_ids in the seeded catalog.
Assistant
There are duplicate model_ids and disabled rows, so the dedup logic is exercised. Let me clean up temp files and run the broader test suite.
Assistant
All 180 route tests pass. Let me run the full server test suite to ensure nothing else breaks.
Assistant
All 456 tests pass. Let me check if there's documentation about
/v1/modelsthat should be updated.Assistant
The README just notes the endpoint exists. Let me review the final handler once more to confirm correctness.
Assistant
The implementation looks correct. Let me verify the build once more and check git status for leftover temp files.
Assistant
Only
proxy.tsis modified, no temp files remain, build succeeds, and all 456 tests pass. Let me do a final review of the complete diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.