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 explore the repository structure first.
Assistant
This is the admin
/modelsroute. But the issue is aboutGET /v1/modelswhich is the OpenAI-compatible endpoint. Let me find that.Assistant
Now let me understand the schema and types involved.
Assistant
Now let me look at the tests related to
/v1/modelsto understand expectations.Assistant
Now let me check the schema of the models table, especially
key_idandenabled.Assistant
Let me look at the test helpers and other tests touching
/v1/models.Assistant
No matches there. Let me check what those grep hits earlier were about.
Assistant
Let me check the router service and how model availability is determined elsewhere.
Assistant
Let me look at the top of proxy.ts for context on imports and types.
Assistant
Let me check existing tests for any expectations about the
/v1/modelsresponse shape or filtering.Assistant
Let me check where
ModelListRowis used across the codebase.Assistant
Now let me view the exact handler region to replace.
Assistant
Now let me update the
ModelListRowtype in shared/types.ts.Assistant
Now let me replace the
/modelshandler in proxy.ts.Assistant
Now let me typecheck and build the server to make sure it compiles.
Assistant
Typecheck passes. Now let me write a temporary test script to validate the new behavior.
Assistant
Let me create a temporary test script to validate the behavior.
Assistant
Let me verify the dedup-across-platforms logic more concretely by inspecting the seed for shared model_ids.
Assistant
The seed has unique model_ids per platform. Let me make the dedup test actually exercise the cross-platform path by inserting a duplicate row.
Assistant
No python3. Let me use node or sed. Let me just rewrite the test file directly.
Assistant
Let me just recreate the whole temp test file with the improved dedup test.
Assistant
All tests pass including the cross-platform dedup. Now let me run the existing related tests to ensure nothing broke.
Assistant
Now let me run the full server test suite to make sure nothing else broke.
Assistant
All 456 tests pass. Let me refine the ordering to sort by the representative row's rank (matching the previous filtered behavior more closely), rather than relying on Map insertion order.
Assistant
There's a duplicate
res.jsonline. Let me fix it.Assistant
Now let me re-typecheck and re-run the temp test plus the related existing tests.
Assistant
All tests pass. Let me remove the temp test and run the full suite.
Assistant
Let me check if the client/frontend consumes
/v1/modelsand might depend on the response shape.Assistant
No client/docs references. Let me do a final review of the diff.
Assistant
The diff looks complete and correct. Let me run the server build to be thorough.
Assistant
Let me check whether the build output (
dist) is gitignored so it doesn't get submitted.Assistant
dist/is gitignored and only my two source changes are staged. Let me do a final review of the complete handler.Assistant
The implementation is complete and verified. Let me run the full test suite one final time to confirm everything is green before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.