How to Switch Models in Claude Code | Choosing Between Sonnet, Opus, and Haiku
"I want to use Opus in Claude Code, but I'm not sure how to switch." "It's tedious to change the model every time." If you've used Claude Code, you've likely run into these situations.
Claude Code supports multiple models--Sonnet, Opus, and Haiku--and lets you switch between them freely. By choosing the right model for each task's complexity, you can balance quality against cost (usage limit consumption).
This article covers three ways to switch models, based on Anthropic's official documentation. Whether you need a quick one-time change or a permanent default, there's an approach that fits.
Available Models in Claude Code
Here's an overview of the models available in Claude Code.
| Model | Model ID | Characteristics |
|---|---|---|
| Sonnet 4.5 | claude-sonnet-4-5-20250929 | Default. Best for everyday coding. Well-balanced |
| Opus 4.5 | claude-opus-4-5-20251101 | Most capable. For complex reasoning and architecture design |
| Haiku 4.5 | claude-haiku-4-5-20251001 | Fast and low-cost. For simple tasks |
Which Model Should You Choose?
Here are some guidelines for choosing the right model.
Sonnet 4.5 (default)
- Day-to-day coding tasks
- Bug fixes and debugging
- Writing tests and documentation
- General refactoring
Opus 4.5
- Complex architecture design
- Investigating difficult bugs
- Major design decisions
- Detailed planning in Plan Mode
Haiku 4.5
- Simple, repetitive tasks
- When you need fast responses
- When you want to conserve usage limits
Note: Opus is highly capable, but it consumes more tokens and you'll hit usage limits faster. Save it for when you really need it.
Method 1: Switch with the /model Command (Easiest)
The /model command is the quickest way to switch models during a session.
Steps
- With Claude Code running, type
/modeland press Enter - A selection menu appears
- Choose the model you want
> /model
Select Model
1. Default (recommended)
2. Opus 4.5
3. Sonnet 4.5
4. Opus 4.5 Plan Mode
Specifying a Model Directly
You can skip the menu and specify a model name or alias directly.
# Using aliases
/model opus
/model sonnet
/model haiku
# Using full model names
/model claude-opus-4-5-20251101
/model claude-sonnet-4-5-20250929
Checking the Current Model
Use the /status command to see which model is currently active.
/status
Method 2: Specify a Model at Startup with --model
If you want to use a different model for a specific session, pass the flag when launching Claude Code.
# Start with Opus
claude --model opus
# Start with Sonnet
claude --model sonnet
# Start with Haiku
claude --model haiku
# Full model names also work
claude --model claude-opus-4-5-20251101
The model specified this way only applies to the current session. The next time you launch Claude Code, it reverts to the default.
Method 3: Change the Default Model (Permanent)
If you always want to use the same model, you can change the default via an environment variable.
Steps
1. Check your shell type
echo $SHELL
/bin/zsh-- zsh (macOS default)/bin/bash-- bash (Linux default)
2. Add the variable to your shell config
For zsh (macOS):
echo 'export ANTHROPIC_MODEL="claude-opus-4-5-20251101"' >> ~/.zshrc
For bash (Linux):
echo 'export ANTHROPIC_MODEL="claude-opus-4-5-20251101"' >> ~/.bashrc
3. Apply the changes
# For zsh
source ~/.zshrc
# For bash
source ~/.bashrc
4. Restart your terminal and launch Claude Code
From now on, the specified model will be used as the default.
Using a Settings File
If you want different default models per project, you can specify the model in .claude/settings.json.
{
"model": "opus"
}
Model Aliases
Claude Code provides aliases with special behavior.
| Alias | Behavior |
|---|---|
default | Recommended settings based on your account type. For Max users, automatically falls back to Sonnet when approaching usage limits |
sonnet | Latest Sonnet model |
opus | Latest Opus model |
haiku | Latest Haiku model |
opusplan | Automatically switches to Opus for Plan Mode and Sonnet for execution |
sonnet[1m] | Enables 1 million token context window (API usage only) |
opusplan: Opus for Planning, Sonnet for Execution
opusplan automatically switches between models depending on the mode.
How it works:
- In Plan Mode -- Uses Opus (strong at complex reasoning and design)
- In execution mode -- Switches to Sonnet automatically (fast and efficient)
To set it up:
/model opusplan
Or at startup:
claude --model opusplan
Usage Limits on the Pro Plan
Opus is available on the Pro plan ($20/month), but there are some things to be aware of.
According to the official help center, using Opus with Claude Code on the Pro plan requires enabling and purchasing "Extra Usage." This means Opus may be unavailable or heavily restricted within the Pro plan's base allocation.
If you plan to use Opus frequently, consider upgrading to a Max plan ($100 or $200/month).
Things to Keep in Mind When Switching Models
Switching Mid-Session Increases Token Consumption
When you switch models during a session, the new model needs to process the entire conversation history, which increases token consumption.
For long conversations, starting a fresh session may be more efficient than switching mid-conversation.
Priority Order for /model and --model
When models are specified through multiple methods, they're applied in this priority order:
/modelcommand (in-session override takes highest priority)--modelflag (startup specification)ANTHROPIC_MODELenvironment variable- Settings file (
.claude/settings.json)
FAQ
Q. Is conversation history preserved when switching models?
Yes. However, the new model needs to reprocess the conversation history, which consumes additional tokens.
Q. Can Haiku handle real development work?
Yes. Haiku is perfectly practical for simple tasks. It's a good option when you want to conserve your usage limits.
Q. Can I switch models in the VS Code extension?
Yes. In the VS Code extension, you can select /model from the / command menu or change the default model in the settings panel.
Q. How do I reset a custom default model?
If you set it via an environment variable, remove the relevant line from your .zshrc or .bashrc, run the source command to apply the changes, and restart your terminal. The default (Sonnet) will be restored.
Summary
Here are the three ways to switch models in Claude Code:
| Method | Use Case | Example |
|---|---|---|
/model | Quick switch during a session | /model opus |
--model | Launch a specific session with a different model | claude --model opus |
| Environment variable | Permanently change the default model | ANTHROPIC_MODEL="..." |
Sonnet (the default) is sufficient for most tasks, but switching to Opus when tackling complex design work or difficult bugs can yield better results.
Find the right balance between your usage limits and task requirements, and choose accordingly.