Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION /v1/models: return the full catalog with per-model availability +…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. GLM Assistant

    This appears to be a JavaScript/TypeScript project. Let me look at the structure more.

  4. GLM Assistant

    Now let me look at the models route file and related services.

  5. GLM Assistant

    Let me find the /v1/models endpoint specifically.

  6. GLM Assistant

    Let me look at the proxy router and app.ts.

  7. GLM Assistant

    Let me view the full /models endpoint section in proxy.ts.

  8. GLM Assistant

    Let me open the proxy.ts file at the models endpoint to see the exactcode.

  9. GLM Assistant

    Now let me understand the database schema better, particularly the models and api_keys tables and the key_id column.

  10. GLM Assistant

    Let me look at the existing tests for the /v1/models endpoint.

  11. GLM Assistant

    Let me check where ModelListRow is used and look at the catalog-sync service to understand how keys/models relate.

  12. GLM Assistant

    Let me look at the router service to understand how "available"/connected models are determined there for consistency.

  13. GLM Assistant

    Let me check the server package.json and test config to know how to run tests.

  14. GLM Assistant

    Let me first run the existing relevant tests to confirm they pass before making changes.

  15. GLM Assistant

    Let me look at the test seed to understand the catalog and key setup used in tests.

  16. GLM Assistant

    Let me check the migrations around V4 to understand the moonshot/minimax disabling.

  17. GLM Assistant

    Let me check the V4 migration that drops moonshot/minimax, to understand whether those seeded rows are disabled.

  18. GLM Assistant

    Now I have a good understanding. Let me write a reproduction script to confirm the current behavior first, then implement the fix. Let me create a temporary test file.

  19. GLM Assistant

    The current behavior returns only auto because my test's POST to /api/keys is gated and failed (no dashboard token). Let me look at the auth helper and fix my reproduction script.

  20. GLM Assistant

    The current behavior is confirmed: default returns only connected models (10 entries with a groq key). Now let me implement the fix. First, update the shared type ModelListRow.

  21. GLM Assistant

    Now let me update the proxy.ts /v1/models handler.

  22. GLM Assistant

    Now let me run my temporary test to verify the new behavior.

  23. GLM Assistant

    The new behavior works as expected. Let me write a more thorough test to verify the dedup "prefer available" logic and edge cases.

  24. GLM Assistant

    All my temporary tests pass, including the dedup preference. Now let me run the existing tests that touch /v1/models and related routes to make sure I didn't break anything.

  25. GLM Assistant

    Now let me run the full server test suite to ensure nothing else breaks.

  26. GLM Assistant

    All 456 tests pass. Let me verify the TypeScript compiles cleanly (including the shared types change).

  27. GLM Assistant

    Let me check whether the client (dashboard) consumes /v1/models or ModelListRow in a way that might be affected.

  28. GLM Assistant

    Let me check docs and README for any /v1/models references that should be keptconsistent.

  29. GLM Assistant

    Let me verify the disabled annotation reflects actual DB state by querying directly.

  30. GLM Assistant

    The disabled annotation correctly reflects actual DB state (110 rows → 106 unique model_ids + auto = 107 entries). Let me do a final review of the complete diff.

  31. GLM Assistant

    Let me confirm no temporary test files are left behind and the workspace is clean.

  32. GLM Assistant

    The temporary test file is already removed (only the two source files are modified). Let me run the full server test suite one final time to confirm everything passes.

  33. GLM Assistant

    All 456 tests pass. Let me do a final type-check on the server to be safe.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.