Claude Code Models
A working guide to picking Sonnet, Opus, Haiku, or opusplan in Claude Code, cutting model costs 60-80% without losing quality.
Problem: A lot of developers reach for Opus on every task and burn through their budget, or stay on Haiku where it cannot keep up. Switching models based on what the task actually needs can pull 60-80% out of your usage costs.
Quick Win: Make Sonnet your default model right now:
claude --model sonnet
You save around 80% on cost and keep strong performance on roughly 90% of daily development work.
Model Aliases
Claude Code ships aliases so you can avoid memorizing version numbers. These are the shortcuts you reach for every day:
| Alias | Behavior |
|---|---|
default | Recommended model for your account type. Max users get auto-fallback from Opus to Sonnet at limits |
sonnet | Latest Sonnet model (currently Sonnet 4.5) for daily coding tasks |
opus | Opus model (currently Opus 4.6) for complex reasoning |
haiku | Fast and efficient Haiku model for simple tasks |
sonnet[1m] | Sonnet with a 1 million token context window for long sessions (Console/API users) |
opusplan | Uses Opus during plan mode, then switches to Sonnet for execution automatically |
The default alias tracks your account type. On certain Max accounts, Claude Code automatically falls back from Opus to Sonnet at a usage threshold, so you keep working without touching a model flag.
Console and API users get sonnet[1m], which opens a 1 million token context window. Long sessions that would otherwise trip the compaction limit sit inside it comfortably. Extended context models bill at different rates, so keep that in mind.
Console and API users can also append the [1m] suffix to a full model name:
/model anthropic.claude-sonnet-4-5-20250929-v1:0[1m]
The Smart Model Strategy
The most expensive habit is running one model for everything. Claude Code gives you several, each tuned for a different kind of work. Swap between them and you can cut usage costs by 80% while the results get better.
Sonnet: Your Daily Driver
Best for: 90% of development work
# Start Claude Code with Sonnet (usually the default)
claude --model sonnetPerfect for:
- Feature implementation and bug fixes
- Code reviews and refactoring
- API integration and database work
- Writing tests and documentation
Why Sonnet wins: 90% of Opus capability at 2x the speed, rarely hits usage limits, ideal for pair programming workflow.
Opus: The Heavy Hitter
When to upgrade: Complex architectural decisions only
# Start with Opus for deep analysis sessions
claude --model opusUse Opus for:
- Large-scale refactoring across multiple systems
- Complex debugging with intricate dependencies
- Architectural decisions requiring deep reasoning
- Advanced security reviews
Cost reality: 5x more expensive than Sonnet, but justified for tasks requiring maximum reasoning power.
Haiku: The Speed Demon
When to downgrade: Simple, repetitive tasks
# Fast and cheap for basic operations
claude --model haikuPerfect for:
- Simple file reads and formatting
- Basic syntax validation
- Quick status checks
- Text transformations
Warning: Don't use Haiku for actual development. It struggles with complex logic and multi-file projects.
Opusplan: The Best of Both Worlds
When to use: Complex tasks where you want Opus reasoning without Opus costs for everything
# Hybrid mode: Opus plans, Sonnet executes
claude --model opusplanHow it works:
- In plan mode: Uses Opus for complex reasoning and architecture decisions
- In execution mode: Automatically switches to Sonnet for code generation and implementation
The planning phase runs on Opus for the deep reasoning, then execution drops to Sonnet for the speed and cost on the code-writing pass. Opus quality lands where it matters (up front), and the rest of the session stays cheap.
Refactoring sessions, feature planning, and any workflow that leans on plan mode are a good fit for opusplan. Because Opus pricing only applies during planning, it doubles as a cost optimization tactic.
Tactical Model Switching
Start with Sonnet. Escalate when the task actually demands it.
During Development Sessions
# Start your session with Sonnet
claude --model sonnet
# Mid-session: switch to Opus for complex refactoring
/model opus
# Back to Sonnet for regular work
/model sonnet
# Drop to Haiku for simple tasks
/model haikuCost Optimization Pattern
- Default: Sonnet for all standard development
- Hybrid: Use
opusplanfor sessions that mix planning and implementation - Escalate: Switch to full Opus only when Sonnet struggles on execution tasks
- Delegate: Use Haiku for simple file operations
- Monitor: Track usage to optimize model selection
Run it this way and your bill drops 60-80% against a pure-Opus workflow.
Model Selection by Task Type
Code Analysis Speed Rankings
- Haiku: Instant but shallow analysis
- Sonnet: Fast with excellent depth
- Opus: Slower but deepest analysis
Reasoning Quality Rankings
- Opus: Superior for complex multi-step problems
- Sonnet: Excellent for most development scenarios
- Haiku: Basic reasoning only
Cost Efficiency Rankings
- Haiku: Cheapest per task (limited capability)
- Sonnet: Best performance per dollar
- Opus: Premium pricing for premium capability
Model Configuration
There are several places to set your model, and the priority chain is strict. A higher-priority setting always beats a lower one:
- During session -
/model <alias|name>switches models mid-session (highest priority) - At startup -
claude --model <alias|name>sets the model for that session - Environment variable -
ANTHROPIC_MODEL=<alias|name>persists across sessions - Settings file - The
modelfield in settings.json for permanent configuration (lowest priority)
To pin a model permanently, add a model field to your settings file:
// ~/.claude/settings.json
{
"permissions": {},
"model": "sonnet"
}With that in place, you stop passing --model every time you start Claude Code.
Controlling Which Models Aliases Map To
Pointing an alias at a specific version, or at a Bedrock or Vertex deployment, is done through environment variables:
| Environment Variable | Controls |
|---|---|
ANTHROPIC_DEFAULT_OPUS_MODEL | Model used for opus, and for opusplan during plan mode |
ANTHROPIC_DEFAULT_SONNET_MODEL | Model used for sonnet, and for opusplan during execution |
ANTHROPIC_DEFAULT_HAIKU_MODEL | Model used for haiku and background functionality |
CLAUDE_CODE_SUBAGENT_MODEL | Model used for sub-agents (overrides the default sub-agent model) |
Note that ANTHROPIC_SMALL_FAST_MODEL is deprecated. ANTHROPIC_DEFAULT_HAIKU_MODEL replaces it.
Bedrock, Foundry, and Vertex users lean on these the most, since those platforms want inference profile ARNs, deployment names, or version names rather than the standard Anthropic model IDs.
Checking Your Current Model
Two ways to see what model a session is on:
- Run
/statusto display your current model and account information - Configure a StatusLine to show the model persistently in your terminal
Prompt Caching Configuration
Prompt caching is on by default in Claude Code and helps with both performance and cost. If you need to turn it off, for debugging, benchmarking, or a specific API setup, these environment variables control it:
| Environment Variable | Effect |
|---|---|
DISABLE_PROMPT_CACHING | Disables caching for all models (overrides per-model) |
DISABLE_PROMPT_CACHING_HAIKU | Disables caching for Haiku models only |
DISABLE_PROMPT_CACHING_SONNET | Disables caching for Sonnet models only |
DISABLE_PROMPT_CACHING_OPUS | Disables caching for Opus models only |
Set any of these to 1 to turn caching off. The global DISABLE_PROMPT_CACHING wins over the per-model flags. Disabling caching raises cost and latency, so only do it when there is a specific reason.
Common Model Selection Mistakes
Mistake 1: Using Opus for everything
- Problem: 5x higher costs with slower responses
- Solution: Default to Sonnet, escalate selectively
Mistake 2: Staying on Haiku too long
- Problem: Poor code quality, missed issues
- Solution: Upgrade to Sonnet for any real development
Mistake 3: Not switching models mid-session
- Problem: Using wrong model for current task
- Solution: Use
/model opusor/model sonnetto switch instantly
Quick Reference
| Task Type | Recommended Model | Why |
|---|---|---|
| Daily coding | Sonnet | Best balance of speed and capability |
| Plan + implement | opusplan | Opus reasoning for plans, Sonnet for code |
| Complex architecture | Opus | Maximum reasoning depth |
| Simple file ops | Haiku | Fast and cheap |
| Long sessions | sonnet[1m] | 1M token window avoids compaction |
| Debugging | Start Sonnet, escalate to Opus if stuck | Progressive escalation |
For beginners: Start with Sonnet to learn workflows.
For daily development: Sonnet as default with Opus for complex debugging.
For budget optimization: Strategic switching based on task complexity.
For learning: Check our configuration guide to set up model defaults.
Pick the right model per task and you write code faster while spending less. Sonnet's balanced power handles most of the job. Opus is for the parts that genuinely need its depth.
Next Action: Set up your optimal model configuration with our performance optimization guide, then learn advanced context management techniques.
For detailed specs on every Claude model Anthropic has released, see the complete model timeline.
Related Guides:
- Deep Thinking Techniques - When to use extended thinking with Opus
- Efficiency Patterns - Build frameworks for consistent output
- Usage Optimization - Track and reduce your costs
Stop configuring. Start building.