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
Now let's write the new query. I'll design a subquery that computes, per model_id, whether any row is available, and then dedup preferring available rows.
Assistant
Let's test SQL directly with a quick node script using better-sqlite3 to confirm alias referencing works in window functions.
Assistant
Query works correctly. Now let's clean up test file and implement in the route.
Assistant
Now update
ModelListRowtype in shared/types.ts and the route implementation.Assistant
Now update the route in proxy.ts.
Assistant
Type-check passes. Now let's run the relevant tests.
Assistant
Now let's run the whole test suite to check nothing else broke, and check any other place referencing
/v1/modelsbehavior (e.g., docs, client).Assistant
All 456 tests pass. Now let's write a quick manual reproduction script to verify the new behavior end-to-end (full catalog vs filtered).
Assistant
This confirms full catalog with per-model annotation, and the
?available=truefilter returning only "auto" (connected models) when no keys exist. Let's test with a key added, and test theconnected=truealias and dedup preference.Assistant
Both filters work correctly and match old behavior (auto + 9 groq models = 10). Let's clean up temp scripts.
Assistant
Let's check the client code that might consume
/v1/modelsto ensure additive fields don't break anything there.Assistant
No client usage of
/v1/models. Let's also double checkdocsfor any relevant description that should be updated.Assistant
This is generic and doesn't need updates. The implementation looks complete. Let's view the final diff.
Assistant
This looks complete and correct. Let's run full test suite once more (including client if any) to be safe.
Assistant
All 456 tests pass. Now let's check the checklist items.
Assistant
The changes are clean and minimal. Let's go through the checklist:
Checklist review:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.