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 check the test file for proxy-auto-model to understand format expectations, and check migrations for models table schema.
Assistant
Now let's look at the test file to understand testing patterns and expectations.
Assistant
Now let's implement the changes. First update the shared type ModelListRow, then the query and endpoint code.
Assistant
Now update the endpoint code in proxy.ts.
Assistant
Now let's build and run the tests to check TypeScript compiles and behavior works.
Assistant
Tests pass. Now let's run full test suite to ensure nothing else broke, and check TypeScript build.
Assistant
TypeScript compiles fine. Now let's run the whole test suite for the server.
Assistant
All 456 tests pass. Now let's write a quick manual test script to verify the new behavior (full catalog vs filtered).
Assistant
Behavior confirmed working correctly. Now let's clean up the temporary test file.
Assistant
Now let's check other places referencing
/v1/modelsto see if there's documentation that should be updated (README.md), and check openai-compat.ts / providers/index.ts for any related model listing code that might need consistency (not required but let's check).Assistant
This is a general mention, no specific need to update. The change is complete and minimal. Let's do a final diff review.
Assistant
The diff looks correct and complete. Let's run the full test suite once more to be safe.
Assistant
All 456 tests pass. Let's review the checklist.
Checklist Review
-
If an error was reported in the issue description, I have successfully reproduced it. — This wasn't a bug report but a feature request (endpoint behavior change). I confirmed the current behavior (only connected models returned, no annotation fields) by reading
proxy.tsbefore making changes, and verified the "current" state matched the issue description. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. — Not an error scenario; instead I verified the new behavior via a temporary test script (since removed) that confirmed: (1) full catalog returned by default (107 entries vs. 1 with no keys added), (2)
?available=truefilter restores old behavior, (3)available/unavailable_reasonfields correctly reflectdisabledvsno_keyvs available states, (4) dedup prefers the available instance of a model id, (5)autois alwaysavailable: true.
-
Assistant
-
Edge cases considered:
- Model rows where
key_idis set (per-key restriction) vsNULL(any enabled key of platform serves it) — both handled via the sameEXISTSjoin used previously. - Multiple rows for the same
model_idacross platforms/keys — dedup viaROW_NUMBER()now orders by "available first" (0 before 1 in the CASE, ascending) thenintelligence_rank,id, so an available instance is always preferred over disabled/keyless duplicates, per the issue's dedup note. disabledtakes priority overno_keyin when a row is both disabled and has no key (matches the issue's precise definitions: = catalog row disabled, = enabled but no key).
- Model rows where
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.