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 look at the test file for this endpoint to understand expected behavior more precisely.
Assistant
Now let's design the new query. We need per-model-id dedup with "available" preferred, plus reason. Let's write the SQL and route logic.
Assistant
Now let's update the ModelListRow type and the route.
Assistant
Now let's update the route in proxy.ts.
Assistant
No existing boolean query helper. I'll implement simple truthy check accepting "true"/"1".
Assistant
Now let's check the rest of the replacement looks fine and no duplicate lines.
Assistant
Good, looks clean. Now let's check TypeScript compile / build and run tests.
Assistant
No errors. Now let's run the relevant test file.
Assistant
Now let's write a quick script to verify full behavior manually, then run the entire test suite.
Assistant
Let's write a temporary reproduce script to verify full catalog + filter behavior with a running instance.
Assistant
The behavior works as expected - full catalog by default, and filtering with
available=true/connected=truereturns only connected models (just "auto" here since no keys added). Let's clean up the temp test file and run full test suite.Assistant
All 456 tests pass. Now let's check other places that might rely on the old
/v1/modelsbehavior — e.g., desktop or client code that consumes this endpoint.Assistant
No client-side consumers of this specific endpoint. Let's also check docs mentioning
/v1/modelsfor API documentation updates.Assistant
That's a generic mention, no change needed there. Let's verify the git diff for the final review.
Assistant
This diff looks solid. Let's also double check that
unavailable_reasonreturned by better-sqlite3 forNULLvalue is JSnull(not undefined), to match interface.Assistant
Good, confirmed
nullnotundefined. Now let's double check edge case: what if there are zero rows inmodelstable (fresh install) - full catalog with justauto. Also check thekey_idmatching logic didn't change semantics. Let's also verify eslint/build for the whole project just to be safe.Assistant
Now let's check the client app (admin dashboard) which might also use
/v1/models— but that was for the OpenAI clients. Let's check the desktop code and client fetch usage too, and re-run the full server test suite once more for final confirmation.Assistant
That's an unrelated admin route (matches
/api/modelsfromroutes/models.ts), not the OpenAI-compatible/v1/models. No changes needed there.Assistant
All 456 tests pass. Let's finalize by reviewing the checklist.
Assistant
Both files modified as expected, no stray temp test files left.
Checklist review:
- Reproduced the reported issue: Yes — I wrote a temporary test (
__repro.test.ts, removed after use) confirming the old behavior only returned connected models, then verified the new default returns the full catalog withavailable/unavailable_reasonannotations, and that?available=true/?connected=truerestrict to only connected models (previous default behavior). - Confirmed the fix resolves it: Yes — the repro script showed full catalog (131 entries incl. disabled/no_key ones) by default, and filtered results only contained entries when the opt-in flag was passed.
- Reproduced the reported issue: Yes — I wrote a temporary test (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.