Claude Code · Requests and models
There's an issue with the selected model
Fix “There’s an issue with the selected model” in Claude Code: pick a valid model, replace stale IDs, and set the right models for Ollama or proxies.
Message
The exact error
There's an issue with the selected model (claude-haiku-4-5-20251001). It may not exist or you may not have access to it. Run /model to pick a different model.Also appears as:
- Non-interactive mode (-p)
- There's an issue with the selected model (…). It may not exist or you may not have access to it. Run --model to pick a different model.
- Agent SDK (no hint; the structured error is model_not_found)
- There's an issue with the selected model (…). It may not exist or you may not have access to it.
- Switching by name
- Model 'claude-opus-9' not found
Meaning
What does “There’s an issue with the selected model” mean?
Claude Code asked for a model the API doesn’t know or won’t give you. Common reasons are an old dated model ID saved in your settings, a typo, a model your plan or organisation doesn’t include, or a model that your cloud provider or region doesn’t offer yet. Behind a gateway or local server set with ANTHROPIC_BASE_URL, it also appears when that server doesn’t serve the model name Claude Code sends.
Causes
Where is the wrong model set?
- A stale or mistyped model ID in settings,
ANTHROPIC_MODELor--model - A model not included in your plan or allowed by your organisation
- On Bedrock or Google Cloud, a model not yet available in your region
- With Ollama, LiteLLM, OpenRouter or another gateway, a Claude model name the server doesn’t serve, including the Haiku model Claude Code uses for background tasks
- On versions before v2.1.206, an expired login that could no longer refresh
Fix
How do I fix the selected model error?
Pick from the list
Run
/modelwith no argument and choose one of the models available to your account.Use an alias instead of a dated ID
Aliases like
sonnetoropusalways resolve to a current model, so they don’t go stale the wayclaude-…-20251001IDs do. To check whether a dated ID has been retired, look it up in our Claude model IDs list, or browse model IDs for every provider.Using Ollama, OpenRouter or a gateway? Map every model name
Set
ANTHROPIC_MODELto the model your server lists, and point the alias variables at served models too, so every request Claude Code makes resolves.ANTHROPIC_DEFAULT_HAIKU_MODELalso sets the model for background tasks. Each value must be a full model name as your provider spells it. The settings.json builder can put these in theenvblock.macOS / Linux export ANTHROPIC_MODEL="your-served-model" export ANTHROPIC_DEFAULT_SONNET_MODEL="your-served-model" export ANTHROPIC_DEFAULT_OPUS_MODEL="your-served-model" export ANTHROPIC_DEFAULT_HAIKU_MODEL="your-small-served-model" claudeRemove the stale setting
If the wrong model keeps coming back, check where it’s set: the
modelkey in your settings files, theANTHROPIC_MODELvariable, and any--modelflag in scripts or aliases.macOS / Linux echo $ANTHROPIC_MODEL grep -n '"model"' ~/.claude/settings.json .claude/settings.json 2>/dev/nullWindows PowerShell $env:ANTHROPIC_MODEL Select-String -Path $HOME\.claude\settings.json, .claude\settings.json -Pattern '"model"' -ErrorAction SilentlyContinueFor -p and scripts
Pass
--modelwith a valid alias or ID, or setANTHROPIC_MODEL.In the Agent SDK
The error omits the hint because your code sets the model. Set
modelonOptionsin TypeScript orClaudeAgentOptions(model=...)in Python, and handle the structuredmodel_not_founderror to show your own retry or model picker.On an older version, sign in again
Before v2.1.206, an expired login that couldn’t refresh made every model fail with this error. Run
/login, and update Claude Code: current versions report that case asLogin expiredinstead.
Explained
Why does it happen with Ollama, OpenRouter or a proxy?
Pointing ANTHROPIC_BASE_URL at another server changes where requests go, not which model names Claude Code asks for. Unless you map them, it still requests Claude models through the sonnet, opus and haiku aliases, and the Haiku alias also covers background work. If the server doesn’t serve one of those names, the request fails with this error even though your main model works. Anthropic’s model configuration page documents ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL for this. If the server rejects your credential rather than the model, see API Error 401.
Explained
Is “Model … not found” the same error?
Related, but it happens at a different moment. Model 'claude-opus-9' not found appears when you switch by name with /model <name> and Claude Code can’t confirm the model exists; the session keeps its current model. Model "Sonnet5" is not a recognized model id appears when an app or the Agent SDK passes a display name instead of an ID. “There’s an issue with the selected model” is reported when a request is actually sent with a model the API refuses. For context-window errors on a valid model, see Prompt is too long; for plan limits per model family, usage limit reached.
FAQ
Questions people ask
Why do I get “There’s an issue with the selected model” with Ollama or OpenRouter?
With ANTHROPIC_BASE_URL pointing at another server, Claude Code still asks for Claude model names unless you map them, including the Haiku model it uses for background tasks. If the server doesn’t serve one of those names, requests fail with this error. Set ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL to models your server lists.
Should I use a model alias or a full model ID in Claude Code?
Use an alias such as sonnet or opus unless you need a specific version. Aliases resolve to a maintained default, so they don’t break when a dated ID like claude-…-20251001 is retired. Pin a full ID only when you need repeatable behaviour, and check it against the current model list before you save it in settings or scripts.
What does [1m] after a model name mean?
It selects the 1-million-token context window variant, for example opus[1m], sonnet[1m] or claude-opus-4-6[1m]. Only add it to a model that supports a 1M window. Current models such as Opus 4.7 and later and Sonnet 5 already run with 1M by default and need no suffix. Picking from /model avoids typing it by hand.
Related
Related errors
Keep exploring