server: implement GET /v1/models for gateway model discovery#61
Merged
Conversation
The README quickstart recommends CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, but the router has no /v1/models route, so Claude Code's startup discovery request 404s and the flag silently does nothing. Serve the registry's full model list in the Anthropic models-list shape (data[].id/display_name, has_more, first_id/last_id, limit honored). The Anthropic-style aliases (claude-sonnet-5 etc.) are included, which matters because Claude Code only adds discovered ids starting with claude/anthropic to its /model picker; raw provider ids are still listed for other clients.
Owner
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #60.
Problem
The README quickstart recommends
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, but there is no/v1/modelsroute, so Claude Code's startup discovery request (GET /v1/models?limit=1000) falls through and the flag silently does nothing.Change
Single concern: add
GET /v1/models, serving the registry's model list in the Anthropic models-list shape.data[].id+data[].display_name("<model> (<provider>)") +type: "model"has_more,first_id,last_id;limithonored, unknown query params toleratedclaude/anthropic, so the aliases are what actually surface in the/modelpicker; raw provider ids remain listed for other Anthropic-compatible clients.Testing
tests/server.rs(list shape, claude-prefixed aliases present, limit + has_more, unknown query params tolerated)cargo test: 599 passed, 0 failedcargo fmt --all --checkcleancargo clippy --all-targets -- -D warnings: identical pre-existing error count before/after (34), none in touched files