[FEATURE] Discover and list models from custom base URL in `/model` picker
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When using ANTHROPIC_BASE_URL with a local model server that hosts multiple models simultaneously, the /model picker only shows a single custom model (set via ANTHROPIC_MODEL env var). There is no way to switch between multiple locally running models within an active session without exiting Claude Code and relaunching with a different ANTHROPIC_MODEL value.
I run multiple local LLMs concurrently behind a reverse proxy (e.g. one large reasoning model + one fast coding model). My server exposes a standard GET /v1/models endpoint that returns all currently active models — but Claude Code never queries it. The /model menu is limited to 5 hardcoded Anthropic models + exactly 1 custom model slot.
This means switching between local models requires restarting Claude Code, which breaks workflow and loses session context.
Proposed Solution
When ANTHROPIC_BASE_URL is set to a custom endpoint, Claude Code should query GET /v1/models (standard OpenAI-compatible endpoint) on that URL and list all returned models as selectable entries in the /model picker.
For example, if the server returns:
{
"object": "list",
"data": [
{ "id": "ornith-35b", "object": "model" },
{ "id": "qwopus-coder", "object": "model" }
]
}
Then /model should show:
1. Default (recommended) Opus 5 (1M context)
2. Opus (1M context) ...
3. Sonnet ...
4. Sonnet 5 (1M context) ...
5. Haiku ...
6. ornith-35b Custom model (local)
7. qwopus-coder Custom model (local)
Selecting a different local model in /model would update the model field in subsequent API requests. No other protocol changes needed — the server already routes based on the model field in the JSON body.
Alternative Solutions
My current workaround is a .bashrc wrapper function (claude-with) that queries /v1/models before launch to find the specified model and sets ANTHROPIC_MODEL:
# Auto-detects the first active model:
claude-local() {
export ANTHROPIC_BASE_URL=http://localhost:9080
export ANTHROPIC_AUTH_TOKEN=local
export ANTHROPIC_API_KEY=""
local live_model
live_model=$(curl -s http://localhost:9080/v1/models 2>/dev/null \
| grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4 | sed 's/^claude-//')
export ANTHROPIC_MODEL="${live_model:-unknown}[1m]"
export ANTHROPIC_SMALL_FAST_MODEL="$ANTHROPIC_MODEL"
echo "🚀 Claude Code → $live_model"
claude "$@"
}
# Target a specific model by name:
claude-with() {
local target="$1"; shift
export ANTHROPIC_BASE_URL=http://localhost:9080
export ANTHROPIC_AUTH_TOKEN=local
export ANTHROPIC_API_KEY=""
local live_model
live_model=$(curl -s http://localhost:9080/v1/models 2>/dev/null \
| grep -o '"id":"[^"]*"' | cut -d'"' -f4 | grep -i "$target" | head -1 | sed 's/^claude-//')
if [ -z "$live_model" ]; then
echo "⚠️ No SWAI model matching '$target'"
return 1
fi
export ANTHROPIC_MODEL="${live_model}[1m]"
export ANTHROPIC_SMALL_FAST_MODEL="$ANTHROPIC_MODEL"
echo "🚀 Claude Code → $live_model"
claude "$@"
}
This lets me launch with claude-with qwopus or claude-with ornith, but it still only provides one custom model slot in the /model menu during a session. To switch, I have to exit and relaunch.
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
- I start two local LLMs on my machine:
ornith-35b(a 35B general reasoning model) andqwopus-coder(a coding-specialized model with speculative decoding). - Both run concurrently, each on its own port, behind a reverse proxy on
localhost:9080. - I launch Claude Code with
claude-with ornithfor architecture planning. - Once the plan is ready, I want to switch to
qwopus-coderto generate code faster. - Today: I must exit Claude Code (
/exit) and relaunch withclaude-with qwopus, losing my conversational session context. - Desired: I simply type
/model, chooseqwopus-coderfrom the list of running models, and continue in the same session seamlessly.
Additional Context
- Industry standard pattern: Tools like Cursor, Continue.dev, Aider, and OpenCode already query
GET /v1/modelsfrom the configured base URL and dynamically populate their model picker. - Server is ready: The reverse proxy already implements
GET /v1/modelsreturning all active models, and dispatches requests to the right backend based on the"model"field in the JSON request body. - Minimal client change: Only requires querying
GET /v1/modelsonANTHROPIC_BASE_URLand adding the returned model IDs to the/modelinteractive list. - Environment: Claude Code v2.1.231, Linux (Fedora), local models via llama.cpp / llama-server.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗