Claude Code setup guide
How to change or pin a model in Claude Code
Run /model in Claude Code to open the picker, or launch a session with claude --model sonnet. In the picker, press Enter to save it for new sessions or s to switch for this session only. Choose opus for reasoning, haiku for speed or opusplan for planning. Pin a model with a full model name or an ANTHROPIC_DEFAULT_*_MODEL variable.
Last updated · Published
By CWYN · Published · Checked against docs, not run · Claude Code model configuration and environment variables (as of )
1. Choose a model alias for the task
| Alias or reset | What it does | When to use it |
|---|---|---|
sonnet | Tracks your provider's current Sonnet release. | Daily coding, such as adding a feature and its tests. |
opus | Tracks your provider's current Opus release. | Complex reasoning, such as tracing a bug across several components. |
haiku | Selects Haiku for a fast response. | A simple task, such as summarizing a short diff. |
opusplan | Uses Opus in plan mode and Sonnet for execution. | You want Opus to work out a change and Sonnet to implement the approved plan. |
best | Selects the same model as opus. | You want a saved preference that follows Opus releases. |
fable | Selects Fable explicitly. | Your hardest, longest-running tasks. Check the picker for a usage-credit label first. |
sonnet[1m] | Requests a 1 million token context window on Sonnet. | Daily coding that needs a large set of files in context. |
opus[1m] | Requests a 1 million token context window on Opus. | A difficult investigation that needs the larger window. |
default | Clears the model override. | You want to return to your account's runtime default. |
If the model already has a native 1 million token window, adding [1m] leaves its capacity unchanged. For a worked example of opusplan, see the guide to planning with Opus and building with Sonnet (as of ).
2. Look up the version your provider selects
The same alias can resolve to different releases. For example, a session launched with claude --model sonnet uses Sonnet 5.5 on the Anthropic API and Sonnet 4.5 on Amazon Bedrock.
| Provider | opus | sonnet | haiku |
|---|---|---|---|
| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |
| Amazon Bedrock | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |
| Google Cloud's Agent Platform | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |
| Microsoft Foundry | Opus 4.6 | Sonnet 4.5 | Haiku 4.5 |
| Claude Platform on AWS | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |
For a specific release on Amazon Bedrock, supply the inference profile ARN. Microsoft Foundry takes a deployment name, and Google Cloud's Agent Platform takes a version name.
Check your Claude Code version before selecting a recent release. Opus 5.5 needs v2.1.280 or later, Sonnet 5.5 needs v2.1.284 or later, Haiku 5.5 needs v2.1.293 or later, and Fable 5.2 needs v2.1.321 or later. Run claude update to update the CLI.
3. Set the model in priority order
Claude Code uses the first applicable choice in this list. The shell examples use POSIX shell syntax.
- During a session. Type
/model sonnetat the Claude Code prompt to switch directly and save your choice. With/modelalone, highlight a row. Press Enter to switch and write themodelfield in your user settings. Press s to switch for this session only. - At launch. Run
claude --model opusin your terminal to start one session on Opus. - In the launch environment. Run
ANTHROPIC_MODEL=haiku claudeto use Haiku for that invocation. - In a settings file. To start on Opus across projects, add the
modelfield to~/.claude/settings.json. Keep any other keys in the file.{ "model": "opus" } - As the fallback for new sessions. Run
export ANTHROPIC_DEFAULT_MODEL=sonnetin your shell. New sessions launched there use Sonnet when the choices above and your organization settings leave the model unspecified.
To retry an earlier request with the model you just selected, rewind to the original prompt and resend it.
4. Pin a model
An alias such as opus follows your provider's releases. To keep new sessions on one version, use a full model name in ~/.claude/settings.json. For example, add "model": "claude-opus-5-5" for Opus 5.5 on the Anthropic API. To try it for one launch, run claude --model claude-opus-5-5.
To set the startup model from the environment, add export ANTHROPIC_MODEL=claude-opus-5-5 to your shell profile. When launched from a new shell, Claude Code uses that value ahead of the saved model setting. To pin what the opus alias selects, add export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 to the profile instead.
To try that alias mapping for one launch, run this in your terminal.
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5 claude --model opus
The corresponding ANTHROPIC_DEFAULT_*_MODEL variables for Sonnet and Haiku are ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL. The Haiku variable replaces the deprecated ANTHROPIC_SMALL_FAST_MODEL.
5. Choose models for subagents and separate terminals
A subagent that inherits the main conversation's model follows a /model switch. To keep a README checker on Haiku while you reason through a bug on Opus, add model: haiku to the YAML at the top of its definition. See the project subagent example for the file layout. To use an existing definition, give the reviewer subagent in the Claude Code Complete Setup Pack the model you want for reviews.
To run two independent conversations side by side, give each terminal its own launch flag. Both choices apply only to the session you start.
- In the first terminal, run
claude --model opusto investigate the bug. - In the second terminal, run
claude --model sonnetto draft a regression test.
6. Troubleshoot model selection
“There's an issue with the selected model”
A typo in --model, ANTHROPIC_MODEL or a settings file can let Claude Code start and then fail on the first request. Open /model and choose a listed model. If you meant to pin a version, correct the spelling and identifier type in the flag, variable or file that supplied it.
The previous model comes back at startup
Check the startup header. When a project or managed settings file supplies the model, the header names that file. You can override it with /model now. A new session applies the file's setting again. See which Claude Code settings file takes precedence.
Fable says “Requires usage credits”
Fable is an explicit choice on every plan. Depending on your plan and seat tier, Fable usage can bill to usage credits. Look for “Requires usage credits” on its picker row before selecting it with /model fable or launching claude --model fable.
The picker shows no prices on Bedrock
Prices appear when Claude Code talks to the Anthropic API directly or through a gateway that proxies it. Bedrock and other third-party providers leave prices blank. The picker's price is a display label only.
If you switched because a request returned a 529, another model may have capacity. See when switching models helps with a 529 overload.
7. Claude Code models FAQ
How do I restore my account's default model?
Run /model default to clear your override. Claude Code returns to the runtime default for your account.
Does the best alias select Fable?
best resolves to the same model as opus. Choose fable explicitly if you want Fable.
Will a model I try today become tomorrow's default?
Pressing Enter in the picker saves the model in your user settings. To try one temporarily, press s in the picker or start the session with claude --model followed by the alias or model name.
Does ANTHROPIC_BASE_URL change the model?
ANTHROPIC_BASE_URL sets the endpoint that receives requests. Select the model for that endpoint with an alias or its provider-specific name.