How to Change Models in Claude Code
Claude Code gives you access to three different AI models: Opus, Sonnet, and Haiku. Knowing when to switch between them saves money and gets better results.
To change models in Claude Code, type /model followed by the model name: /model opus for complex tasks, /model sonnet for everyday coding, or /model haiku for quick questions at 3x lower cost. You can also set a permanent default with claude --model opus or by adding export ANTHROPIC_MODEL=opus to your shell profile.
Choosing the right model per task can save significant money while getting better results. With Opus 4.6's new pricing ($5/$25 per million tokens vs the old $15/$75), the gap between models is smaller than ever, making Opus more accessible for complex work. This guide covers all three models, their strengths, effort levels, and when to use each one.
What Are Claude Code Models?
Claude Code connects to Anthropic's Claude AI, which comes in three versions (called models). Each model represents a different trade-off between capability and cost:
Claude Opus 4.6 (Latest)
The most capable model. Released February 2026. Best for complex reasoning, architecture decisions, and difficult debugging. Supports adaptive reasoning with configurable effort levels (low, medium, high) and an optional 1 million token context window.
- Best reasoning and analysis of any Claude model
- Handles nuanced, multi-step problems
- Model ID:
claude-opus-4-6 - $5 input / $25 output per million tokens
Claude Sonnet 4.5
The balanced model. Fast, capable, and cost-effective. Handles most coding tasks well. This is the default in Claude Code for good reason.
- Best balance of speed, quality, and cost
- Handles 90% of everyday tasks
- Model ID:
claude-sonnet-4-5-20250929 - $3 input / $15 output per million tokens
Claude Haiku 4.5
The lightweight model. Extremely fast and affordable. Perfect for simple questions, quick lookups, and high-volume tasks where speed matters more than depth.
- Fastest response times
- 5x cheaper than Sonnet, 25x cheaper than Opus
- Model ID:
claude-haiku-4-5-20251001 - $1 input / $5 output per million tokens
How to Switch Models
Method 1: The /model Command (During a Session)
The easiest way to switch models is the /model command:
/model opus # Switch to Opus
/model sonnet # Switch to Sonnet
/model haiku # Switch to Haiku
The change takes effect immediately. Your next prompt uses the new model.
Quick tip: Type /model by itself to see which model you're currently using and get a list of available options.
Method 2: Command Line Flag (Starting a Session)
Start Claude Code with a specific model:
claude --model opus
claude --model sonnet
claude --model haiku
This sets the model for that entire session.
Method 3: Environment Variable (Permanent Default)
Set a default model that persists across all sessions:
# Add to ~/.bashrc or ~/.zshrc
export ANTHROPIC_MODEL=opus
After adding this, run source ~/.bashrc (or restart your terminal) to apply the change.
You can also pin specific model versions for each tier:
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-6"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5-20250929"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5-20251001"
Method 4: One-Off Commands
Use a specific model for a single command without changing your session:
claude --model opus -p "Analyze this architecture and suggest improvements"
When to Use Each Model
| Task | Recommended Model | Why |
|---|---|---|
| Architecture decisions | opus |
Needs deep reasoning about tradeoffs |
| Debugging complex issues | opus |
Better at following logic chains |
| Code review | opus |
Catches subtle issues others miss |
| Everyday coding | sonnet |
Fast, capable, good value |
| Writing tests | sonnet |
Straightforward task, quality matters |
| Refactoring | sonnet |
Balance of speed and accuracy |
| Quick questions | haiku |
Fast answer, low cost |
| File operations | haiku |
Simple task, speed matters |
| Bulk formatting | haiku |
Repetitive work, cost sensitive |
The 90/10 Rule
Sonnet handles 90% of tasks well. Use Opus when you hit a wall or need exceptional quality. Use Haiku when the task is simple and you want speed or savings.
Cost Comparison
Understanding costs helps you make smart model choices:
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Relative Cost |
|---|---|---|---|
| Opus 4.6 | $5.00 | $25.00 | ~1.7x Sonnet |
| Sonnet 4.5 | $3.00 | $15.00 | Baseline |
| Haiku 4.5 | $1.00 | $5.00 | 3x cheaper |
Note: Opus 4.6 pricing is significantly lower than the previous Opus 4.1 generation ($15/$75). It is now much closer to Sonnet in cost while offering substantially better reasoning.
In practical terms:
- A typical coding session (50K tokens) costs about $0.90 with Sonnet, $1.50 with Opus, or $0.30 with Haiku
- Heavy daily use (500K tokens) costs about $9 with Sonnet, $15 with Opus, or $3 with Haiku
Claude Code also uses prompt caching by default, which reduces input costs by up to 90% for repeated context. The Batch API offers an additional 50% discount for non-urgent workloads.
Cost tip: Check your spending with the /cost command. It shows token usage for your current session. Use /stats for longer-term tracking.
Setting a Default Model
If you want a different default than Sonnet, you have several options:
Option 1: Environment Variable
# In ~/.bashrc or ~/.zshrc
export ANTHROPIC_MODEL=opus
Option 2: Shell Alias
# In ~/.bashrc or ~/.zshrc
alias claude-opus="claude --model opus"
alias claude-haiku="claude --model haiku"
Now you can run claude-opus or claude-haiku directly.
Option 3: Project-Specific Default
Add this to your project's CLAUDE.md file:
## Model Preference
Use Opus for this project. The codebase is complex and benefits
from deeper reasoning.
Claude will see this preference when working in that project directory.
Switching Models Mid-Session
A powerful workflow is switching models during a single session:
- Start with Sonnet for initial exploration and simple tasks
- Switch to Opus when you hit a complex problem that needs deeper analysis
- Switch to Haiku for cleanup tasks like formatting or simple file operations
> Refactor the authentication module
[Sonnet handles this well]
> /model opus
> The refactored auth is failing edge cases. Analyze the logic
> and find what I'm missing.
[Opus provides deeper analysis]
> /model haiku
> Update the copyright year in all files to 2026
[Haiku handles simple bulk operations cheaply]
Model Aliases
Claude Code supports convenient model aliases so you don't need to remember exact version numbers. Aliases always point to the latest version of that model tier.
| Alias | Current Model | Best For |
|---|---|---|
opus |
Claude Opus 4.6 | Complex reasoning, architecture |
sonnet |
Claude Sonnet 4.5 | Everyday coding, balanced tasks |
haiku |
Claude Haiku 4.5 | Simple tasks, bulk operations |
opusplan |
Opus (plan) + Sonnet (execution) | Best of both: Opus reasoning + Sonnet speed |
sonnet[1m] |
Sonnet with 1M token context | Long sessions, large codebases |
default |
Varies by account type | Recommended setting for your plan |
The opusplan alias is particularly powerful: it uses Opus for complex reasoning during plan mode, then automatically switches to Sonnet for code generation and implementation. This gives you superior planning at lower execution cost.
Effort Levels
Opus 4.6 supports adaptive reasoning with configurable effort levels. This lets you control the depth of thinking based on task complexity:
- Low: Faster and cheaper. Good for straightforward tasks where deep reasoning isn't needed.
- Medium: Balanced reasoning depth.
- High (default): Deepest reasoning. Best for complex problems.
Set effort three ways:
# In the /model picker: use left/right arrow keys
# Via environment variable:
export CLAUDE_CODE_EFFORT_LEVEL=medium
# In settings.json:
{ "effortLevel": "high" }
Extended Context (1M Tokens)
For long sessions or large codebases, append [1m] to enable a 1 million token context window:
/model sonnet[1m]
/model opus[1m]
Note that extended context models have different pricing. Requests exceeding 200K input tokens are charged at premium rates (roughly 2x for input, 1.5x for output). For most sessions, the standard context window is sufficient.
Model Capabilities Comparison
| Capability | Opus | Sonnet | Haiku |
|---|---|---|---|
| Complex reasoning | Excellent | Good | Basic |
| Code generation | Excellent | Very Good | Good |
| Following instructions | Excellent | Very Good | Good |
| Speed | Slower | Fast | Very Fast |
| Context handling | Best | Great | Good |
Common Mistakes
- Always using Opus: Although Opus 4.6 pricing has dropped significantly ($5/$25 vs the old $15/$75), Sonnet still handles most tasks at lower cost.
- Never using Opus: When Sonnet struggles, people often assume it's their prompt. Sometimes you just need a more capable model. With Opus 4.6's new pricing, the cost gap is much smaller.
- Ignoring Haiku: For simple tasks, Haiku is 3x cheaper than Sonnet. Those savings add up on repetitive work.
- Forgetting /cost: Track your usage. Knowing what you spend helps you make better model choices.
- Not setting defaults: If you always want Opus, set the environment variable. Don't type
/model opusevery session.
FAQ
Does switching models lose my conversation context?
No. Your conversation history stays intact when you switch models. The new model picks up where the old one left off.
Can I use different models in the same prompt?
No. Each prompt goes to one model. But you can switch models between prompts as often as you want.
Which model is best for writing code?
Sonnet is best for most coding tasks. Use Opus for complex architecture or when Sonnet's output isn't meeting your standards.
Why would I ever use Haiku for coding?
Haiku excels at simple, well-defined tasks: renaming variables, updating imports, formatting code, generating boilerplate. It's fast and cheap for repetitive work.
How do I know which model I'm currently using?
Type /status to see your current model and account information. You can also check the status line if configured, or type /model by itself to see the current model and available options.
What is the opusplan model?
The opusplan alias is a hybrid mode that uses Opus for plan mode (complex reasoning and architecture) and automatically switches to Sonnet for execution (code generation and implementation). This gives you the best of both models.
What are effort levels?
Effort levels (low, medium, high) control how deeply Opus 4.6 reasons about your request. Use low effort for simple tasks and high effort for complex problems. Adjust via the /model picker with left/right arrow keys, or set CLAUDE_CODE_EFFORT_LEVEL in your environment.
Related Guides
- Claude Code Pricing Guide — understand all costs
- Slash Commands in Claude Code — all the shortcuts including /model
- Write Better Prompts for Claude Code — get more from any model
Like Claude Code? Meet Your Chief AI Officer
Watch me build a complete website using only plain English—no coding required. Then try it yourself.
Get the Free Blueprint href="/blueprint">Watch the Free Setup Video →rarr;