Claude Sonnet vs Opus vs Haiku: Which Model for Which Task? (2026)
Claude Code gives you three models, and most developers use the wrong one for the job. Opus for a simple rename refactor wastes $0.15 when Haiku does it for $0.003. Haiku for a cross-service architecture decision produces shallow results that need three follow-up prompts. The right model for the right task cuts costs 40-60% without sacrificing quality where it matters. Use the Model Selector to get instant recommendations, or read the full breakdown below.
The Three Models at a Glance
| Attribute | Haiku 3.5 | Sonnet 4.6 | Opus 4.6 |
|---|---|---|---|
| Input cost | $0.25/M tokens | $3.00/M tokens | $15.00/M tokens |
| Output cost | $1.25/M tokens | $15.00/M tokens | $75.00/M tokens |
| Speed (tokens/sec) | ~180 | ~90 | ~40 |
| Context window | 200K | 200K | 200K |
| Best for | Simple, repetitive | General coding | Complex reasoning |
| Cost vs Opus | 1x (baseline) | 5x | 20x |
The cost difference is not linear with quality. Sonnet delivers roughly 90% of Opus quality at 20% of the cost for standard coding tasks. Haiku delivers about 75% of Opus quality at 5% of the cost for simple tasks.
Task-by-Task Comparison
Debugging
Haiku: Handles single-file bugs with clear stack traces. If the error message points to the problem, Haiku finds and fixes it.
Sonnet: Handles multi-file bugs where the root cause is 2-3 layers removed from the symptom. Follows import chains, checks type definitions, traces data flow.
Opus: Handles architectural bugs – race conditions, state management issues across services, subtle type system edge cases. Opus considers interactions between components that other models miss.
# Example: "Users see stale data after updating profile"
Haiku → "Add cache invalidation after the update call" # Surface fix
Sonnet → "The TanStack Query cache key doesn't include the # Correct fix
user ID, so updates to one user show stale data
for another"
Opus → "The optimistic update assumes the mutation response # Root cause
shape matches the query response, but the API returns
a partial object. The cache merge creates a hybrid
that passes type checks but renders stale fields."
Recommendation: Start with Sonnet. Escalate to Opus only when Sonnet’s first fix doesn’t resolve the issue or when debugging concurrency/state management bugs.
Code Generation
Haiku: Generates boilerplate, CRUD endpoints, type definitions, test stubs. Fast and cheap for code that follows established patterns.
Sonnet: Generates complete features – component + hook + service + test + types. Follows project conventions when guided by CLAUDE.md.
Opus: Generates architecturally complex features – state machines, plugin systems, complex data transformation pipelines. Makes better decisions about abstractions and edge cases.
Recommendation: Haiku for boilerplate, Sonnet for features, Opus for architecture-level generation.
Refactoring
Haiku: Rename variables, extract functions, convert callbacks to async/await. Mechanical transformations where the pattern is clear.
Sonnet: Restructure modules, split large files, migrate from one library to another (e.g., axios to fetch). Understands the “why” behind the refactor.
Opus: Redesign component hierarchies, extract shared abstractions across packages, refactor state management approaches. Sees the system-level implications.
Recommendation: Haiku for mechanical refactors, Sonnet for module-level restructuring, Opus for architectural refactors.
Code Review
Haiku: Catches syntax issues, missing null checks, unused imports. Surface-level review.
Sonnet: Catches logic errors, missing edge cases, performance issues, security vulnerabilities in standard patterns.
Opus: Catches design issues – incorrect abstractions, violated boundaries, subtle correctness bugs, interactions between the change and the broader system.
Recommendation: Sonnet for PR reviews. Use Opus only for reviewing architectural changes or security-critical code.
Documentation
Haiku: Generates JSDoc comments, README sections, basic API docs. Follows templates well.
Sonnet: Generates architecture docs, migration guides, onboarding docs. Understands context and writes for the right audience.
Opus: Generates design documents, RFC-style proposals, technical specifications. Considers tradeoffs and alternatives.
Recommendation: Haiku for API docs, Sonnet for team docs, Opus for design docs.
Cost Comparison: A Real Day of Coding
A typical 8-hour coding day with 40 Claude interactions:
| Strategy | Model Mix | Daily Cost | Quality |
|---|---|---|---|
| All Opus | 40 Opus | $18.00 | Excellent |
| All Sonnet | 40 Sonnet | $3.60 | Very Good |
| Smart Mix | 5 Opus + 25 Sonnet + 10 Haiku | $5.40 | Excellent |
| Budget | 5 Sonnet + 35 Haiku | $0.90 | Good |
The Smart Mix delivers the same quality as All Opus at 30% of the cost. The 5 Opus interactions handle the 5 tasks that actually need deep reasoning. The 25 Sonnet interactions handle standard development. The 10 Haiku interactions handle boilerplate and simple fixes.
Decision Flowchart
Is the task mechanical/repetitive?
├─ Yes → Haiku ($0.003/task avg)
│ Examples: rename, boilerplate, type stubs, imports
└─ No → Does it require multi-file reasoning?
├─ No → Sonnet ($0.09/task avg)
│ Examples: single feature, bug fix, test writing
└─ Yes → Does it involve architecture/design decisions?
├─ No → Sonnet ($0.09/task avg)
│ Examples: multi-file refactor, library migration
└─ Yes → Opus ($0.45/task avg)
Examples: system design, race conditions, security audit
Try It Yourself
Stop guessing which model to use. The Model Selector analyzes your task description and recommends the right Claude model with a cost estimate. Enter what you’re building, and get an instant recommendation – no spreadsheet required.
Can I switch models mid-session in Claude Code?
Yes. Use the /model command to switch between models during a session. Your conversation context carries over, so you can start with Sonnet for initial implementation and switch to Opus when you hit a complex bug.Does Opus always produce better code than Sonnet?
Not for simple tasks. On boilerplate generation, CRUD endpoints, and mechanical refactors, Sonnet and Opus produce nearly identical output. Opus's advantage appears on tasks requiring multi-step reasoning, architectural decisions, or handling subtle edge cases.Is Haiku good enough for production code?
For specific task types, yes. Haiku handles boilerplate generation, type definitions, test stubs, and mechanical refactors at production quality. It struggles with complex logic, edge cases, and multi-file reasoning. Pair it with a good CLAUDE.md and use it for the tasks it excels at.How do I know when to escalate from Sonnet to Opus?
Escalate when Sonnet's first attempt does not solve the problem, when you are debugging a concurrency or state management issue, when you need to make an architectural decision, or when reviewing security-critical code. If Sonnet gets it right on the first try, the escalation would have been wasted.Quick reference → Search all commands in our Command Reference.
Related Guides
- Model Selector – Get instant model recommendations for your task
- Claude Code Cost Calculator – Estimate your monthly Claude Code costs
- Token Estimator Tool – Estimate token usage before you start
- Cost Optimization Guide – Cut Claude Code costs without cutting quality
- Claude Code Best Practices – Production patterns for Claude Code