Skip to content

feat(proxy): add /v1/models endpoint for gateway model discovery#128

Open
jsboige wants to merge 1 commit into
MadAppGang:mainfrom
jsboige:feat/proxy-model-discovery-endpoint
Open

feat(proxy): add /v1/models endpoint for gateway model discovery#128
jsboige wants to merge 1 commit into
MadAppGang:mainfrom
jsboige:feat/proxy-model-discovery-endpoint

Conversation

@jsboige

@jsboige jsboige commented May 16, 2026

Copy link
Copy Markdown

Summary

  • Add GET /v1/models endpoint to the proxy server
  • Returns all routable models from routing rules, profile model mappings, custom endpoints, and the --model flag
  • Enables Claude Code's gateway model discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1)

Details

The endpoint aggregates models from four sources:

  1. Routing rules — model name patterns from DEFAULT_ROUTING_RULES + user config (catch-all * excluded)
  2. Profile model mappings — opus/sonnet/haiku/subagent role mappings from --model-map or config
  3. Custom endpoints — models declared in customEndpoints[].models from ~/.claudish/config.json
  4. Default model — the --model flag if set

Response format follows the OpenAI /v1/models convention:

{
  "object": "list",
  "data": [
    { "id": "claude-sonnet-4-20250514", "display_name": "claude-sonnet-4-20250514", "created_at": "..." },
    ...
  ]
}

Zero new dependencies — uses only existing imports (loadConfig, loadRoutingRules). Config read failures for custom endpoints are silently skipped (proxy stays up).

Test plan

  • bun run build — compiles without errors
  • curl http://localhost:3000/v1/models — returns model list
  • With routing rules + custom endpoints configured, verify all models appear
  • CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 Claude Code session uses the endpoint correctly

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Returns all routable models from routing rules, profile model mappings,
custom endpoints, and --model flag. Claude Code uses this endpoint when
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 is set.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jsboige jsboige force-pushed the feat/proxy-model-discovery-endpoint branch from c73d2d6 to c935f3a Compare May 30, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants