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.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /freellmapi, current file: none) bash-$
- Assistant
I’ll first map the repository and locate the
/v1/modelsroute, model schemas, and relevant tests. Then I’ll reproduce the current filtering behavior, implement catalog-wide availability annotation and query filtering, and run the focused and broader test suites. - Assistant
The server source is mirrored into
node_modules, so I’ll work only in the repository’sserver/tree. Next I’m inspecting route registration, database query helpers, and current route test fixtures to understand how enabled models and keys are represented and deduplicated. - Assistant
The current SQL confirms the reported behavior: disabled and keyless rows are removed before deduplication. I’ll inspect the shared row type, schema definitions, and analogous boolean query handling. I also want to verify migration constraints because
key_idchanges whether a platform key matches a catalog row. - Assistant
ModelListRowis internal and can be additively extended without introducing a public interface. Before changing code, I’ll run a temporary endpoint-level reproduction: initialize the catalog, add only one Groq key, call/v1/models, and compare returned IDs with all distinct catalog IDs. This will make the current omission measurable while leaving repository tests untouched. - Assistant
The first temporary harness hit
tsx’s CommonJS top-level-await restriction before exercising the app. I’ll wrap it in an async function and rerun the same reproduction. - Assistant
The reproduction shows 9 of 106 real model IDs and no annotations. I’ll now change the route so availability is computed per catalog row before deduplication, with ordering
available → enabled/keyless → disabled → rank/id. This preserves the prior rank choice among connected duplicates, prefers any connected duplicate, and gives a sensible"no_key"preference over"disabled"when every duplicate is unavailable. Filtering will happen after deduplication, whileautoremains present and available for both query aliases. - Assistant
Python is unavailable in this image, so no source change occurred. I’ll apply the same targeted replacement using the provided non-interactive editor command, then inspect and type-check it.
- Assistant
The editor found the block but declined because the file was not yet its active buffer; the build therefore only validated the unchanged code. Now that
proxy.tsis open, I’ll replace the exact line range shown and rebuild. - Assistant
I have the exact boundaries; I’ll replace only the route’s database/response body (lines 129–171), retaining authentication and route closure.
- Assistant
The route compiles successfully. I’ll now rerun an expanded endpoint harness to verify: default count equals the distinct catalog plus
auto; every entry has a valid annotation;available=trueandconnected=trueare equivalent; unavailable rows include both expected reasons where present; and filtered results contain only usable entries. - Assistant
The expanded harness passes all functional checks: 107 entries equals 106 distinct catalog IDs plus
auto, annotations and reasons are valid, and both filters return the same 10 all-available entries. The focused Vitest invocation used a root-relative path while the workspace runs fromserver/, so Vitest found no files; I’ll rerun it with the workspace-relative path, then inspect the diff. - Assistant
Focused tests pass, and the diff is limited to the intended route. The SQL/filter ordering preserves the exact old real-model selection for filtered requests while adding
auto’s required annotation. I’ll run the complete server suite now to detect interactions with database migrations, routing, or authentication. - Assistant
All 456 server tests pass. I noticed the pre-existing route comment still claims the endpoint only shows linked models, which is now misleading; I’ll update that comment, then perform final build/diff/status checks.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →