Claude Model Comparison 2026: Haiku vs Sonnet vs Opus
Anthropic’s current lineup — Haiku 4.5, Sonnet 5, Opus 5, and Fable 5.1 — covers a 20× cost range from the cheapest token to the most powerful. Each model is genuinely different: not just a speed-vs-quality tradeoff but different strengths, context windows, and ideal use cases. This guide walks through every model in the Claude 5 family, shows you how to call each one in Python, and ends with a decision framework so you stop defaulting to Opus for tasks that Haiku handles just as well at a fraction of the cost.
If you haven’t set up the SDK yet, Claude API with Python covers installation and your first call. Claude API Pricing goes deeper on cost optimization if that’s your main concern.
The Claude 5 Family at a Glance
| Model | API ID | Best For | Input ($/M tokens) | Output ($/M tokens) | Context Window |
|---|---|---|---|---|---|
| Haiku 4.5 | claude-haiku-4-5-20251001 | High-volume, low-latency tasks | $0.80 | $4 | 200K |
| Sonnet 5 | claude-sonnet-5 | Coding, analysis, everyday tasks | $3 | $15 | 200K |
| Opus 5 | claude-opus-5 | Complex reasoning, research, long docs | $15 | $75 | 200K |
| Fable 5.1 | claude-fable-5-1 | Creative writing, roleplay, narrative | Varies | Varies | 200K |
All four share the same 200K token context window, the same tool use API, and the same streaming interface. Switching models is a single-line change — the API contract is identical.
Haiku 4.5 — Fast, Cheap, Built for Scale
Haiku 4.5 (claude-haiku-4-5-20251001) is the entry-level model in the Claude 5 family. At $0.80/M input and $4/M output, it costs roughly 19× less per token than Opus 5 while still handling a surprisingly wide range of tasks well.
Where Haiku excels:
- Classification and routing — categorize support tickets, route user intent, tag documents
- Data extraction — pull structured fields from unstructured text (names, dates, amounts)
- Simple Q&A and summarization — FAQ bots, document summaries, chat assistants with a narrow domain
- High-volume pipelines — when you’re processing thousands of items per hour and cost matters
- Agent sub-tasks — within a multi-agent system, Haiku handles leaf-node tasks while Opus or Sonnet orchestrates
from anthropic import Anthropic
client = Anthropic()
# Classification with Haiku — cheap enough to run on every user action
def classify_support_ticket(ticket_text: str) -> str:
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=20,
system="Classify the support ticket into one of: billing, technical, account, other. Reply with only the category.",
messages=[{"role": "user", "content": ticket_text}],
)
return response.content[0].text.strip().lower()
result = classify_support_ticket("I was charged twice for my subscription last month.")
print(result) # → billingHaiku is noticeably faster than Sonnet or Opus, which matters when you’re waiting for a response inline in a user request. Latency to first token is typically under 500ms on straightforward prompts.
Where Haiku falls short: multi-step reasoning chains, nuanced writing that requires judgment calls, tasks that benefit from broad world knowledge, and anything where a wrong answer has real consequences. For those, reach for Sonnet or Opus.
Sonnet 5 — The Everyday Workhorse
Sonnet 5 (claude-sonnet-5) is the model most developers should use by default. At $3/M input and $15/M output, it hits the best quality-per-dollar in the family — capable enough for production coding, analysis, and multi-step reasoning, without Opus pricing.
Sonnet 5 is the right choice for:
- Code generation and review — write functions, refactor, explain code, review PRs
- Analysis tasks — synthesize data, compare options, generate reports
- Multi-turn conversations — general-purpose chat assistants with memory
- Document processing — summarize, extract, rewrite long documents
- RAG pipelines — answer questions over retrieved context where you need reliable accuracy
- n8n / automation workflows — the default model for most n8n + Claude workflows
from anthropic import Anthropic
client = Anthropic()
def review_code(code: str, language: str = "python") -> str:
response = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
system=(
"You are a senior code reviewer. Identify bugs, security issues, and "
"style problems. Be specific and concise. Format: bullet list."
),
messages=[
{
"role": "user",
"content": f"Review this {language} code:\n\n```{language}\n{code}\n```",
}
],
)
return response.content[0].text
code_snippet = '''
def get_user(user_id):
query = "SELECT * FROM users WHERE id = " + user_id
return db.execute(query)
'''
print(review_code(code_snippet))
# → - SQL injection vulnerability: user_id is concatenated directly into the query
# - Use parameterized queries: db.execute("SELECT * FROM users WHERE id = ?", (user_id,))
# - No input validation or error handlingSonnet 5 is also what Claude Code uses internally for most coding tasks. If you’re looking for a mental model: it’s the model Anthropic trusts for their own developer-facing product.
Opus 5 — Maximum Capability
Opus 5 (claude-opus-5) is Anthropic’s most capable model. At $15/M input and $75/M output, it’s expensive — but it reaches a level of reasoning, nuance, and knowledge that Sonnet and Haiku can’t match on hard problems.
Use Opus 5 when:
- Complex multi-step reasoning — tasks where intermediate steps compound (math, logic, law, medicine)
- Long document analysis — synthesize a 150-page report with nuanced conclusions
- Research and writing — produce output that needs expert-level judgment, not just a correct answer
- Agent orchestration — Opus makes better routing decisions and writes better sub-task descriptions in a multi-agent system
- Evaluation — use Opus to judge the quality of other models’ outputs (LLM-as-judge)
- One-off tasks where quality matters more than cost
from anthropic import Anthropic
client = Anthropic()
def analyze_contract(contract_text: str) -> str:
response = client.messages.create(
model="claude-opus-5",
max_tokens=2048,
system=(
"You are a senior contract lawyer. Analyze the contract for: "
"unusual clauses, missing standard protections, liability risks, "
"and ambiguous language. Be specific about line numbers or sections."
),
messages=[
{
"role": "user",
"content": f"Analyze this contract:\n\n{contract_text}",
}
],
)
return response.content[0].text
# Use Opus here because a missed liability clause costs far more than the API call
print(analyze_contract(open("vendor_agreement.txt").read()))A practical rule: if you’re using Opus for tasks where Sonnet gives identical results (most coding, basic analysis, chatbots), you’re leaving money on the table. Profile your prompts with Sonnet first; upgrade to Opus only when quality clearly drops.
Fable 5.1 — The Creative Model
Fable 5.1 (claude-fable-5-1) is a specialist model optimized for creative and narrative tasks. It’s a different dimension from the Haiku/Sonnet/Opus tier ranking — rather than “cheaper vs more capable,” Fable is trained for a specific output style.
Fable excels at:
- Interactive fiction and roleplay — character consistency, world-building, narrative branching
- Creative writing — prose quality, voice, stylistic range
- Story-driven applications — games, interactive experiences, educational storytelling
- Character-based chat — personas that need to stay in-character across long conversations
from anthropic import Anthropic
client = Anthropic()
def write_scene(premise: str, style: str = "literary fiction") -> str:
response = client.messages.create(
model="claude-fable-5-1",
max_tokens=800,
system=f"You are a master storyteller writing {style}. Show, don't tell. Use vivid sensory detail.",
messages=[{"role": "user", "content": f"Write an opening scene: {premise}"}],
)
return response.content[0].text
print(write_scene(
"A software engineer discovers their code is being used in ways they never intended",
style="cyberpunk noir"
))For business tasks — analysis, code, data extraction, Q&A — stick to Haiku/Sonnet/Opus. Fable’s creative strengths are a liability when you need factual accuracy and structured output.
How to Choose the Right Model
Start with this decision tree:
- Does latency matter more than quality? Is this a real-time UI response or high-volume batch? → Haiku 4.5
- Is it a routine coding, analysis, or chat task? No edge cases, no unusual judgment required? → Sonnet 5
- Is this a hard reasoning problem, long document, or quality-critical output? Would a human expert need significant effort? → Opus 5
- Is creative writing or character roleplay the core of the task? → Fable 5.1
When in doubt, prototype with Sonnet 5. It’s capable enough that most production tasks don’t need Opus, and it’s fast enough that you’ll notice if you’re under-serving users with Haiku.
Cost Comparison: A Realistic Example
Say you’re building a support chatbot that handles 10,000 conversations per day, each averaging 500 input tokens and 200 output tokens. Here’s the monthly cost breakdown:
| Model | Input tokens/mo | Output tokens/mo | Monthly cost | Annual cost |
|---|---|---|---|---|
| Haiku 4.5 | 150M | 60M | $120 + $240 = $360 | $4,320 |
| Sonnet 5 | 150M | 60M | $450 + $900 = $1,350 | $16,200 |
| Opus 5 | 150M | 60M | $2,250 + $4,500 = $6,750 | $81,000 |
For a FAQ-style support bot with narrow scope, Haiku is the obvious choice: it handles the task, costs $360/month instead of $1,350, and the latency is better. Upgrade to Sonnet only when your bot needs to handle open-ended questions, and Opus only when wrong answers in edge cases have real business consequences.
Mixing Models in a Single Application
Production applications often use multiple models simultaneously. A common pattern: Opus for orchestration and judgment, Haiku for sub-tasks and extraction.
from anthropic import Anthropic
client = Anthropic()
def intelligent_pipeline(user_query: str) -> str:
# Step 1: Haiku extracts intent (cheap, fast)
intent_response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=50,
system="Extract the user's primary intent as a single keyword: refund, status, technical, other",
messages=[{"role": "user", "content": user_query}],
)
intent = intent_response.content[0].text.strip()
# Step 2: Route to the right model based on complexity
if intent == "technical":
# Technical questions need Sonnet's code/reasoning ability
model = "claude-sonnet-5"
system = "You are a technical support engineer. Give precise, actionable answers."
elif intent == "refund":
# Refund policy has nuance — use Sonnet for judgment
model = "claude-sonnet-5"
system = "You are a billing specialist. Apply refund policy carefully."
else:
# Simple queries — Haiku is enough
model = "claude-haiku-4-5-20251001"
system = "You are a friendly customer support agent."
final_response = client.messages.create(
model=model,
max_tokens=512,
system=system,
messages=[{"role": "user", "content": user_query}],
)
return final_response.content[0].text
print(intelligent_pipeline("My payment was declined but money left my account"))This pattern — cheap model for routing, expensive model only where needed — is a standard cost-optimization technique in production LLM systems. The prompt caching guide covers the complementary technique: caching shared context across requests to cut input costs further.
Switching Models: What Changes, What Doesn’t
The API contract is identical across all Claude 5 models, so switching is genuinely a one-line change:
# Switch any call by changing the model parameter
response = client.messages.create(
model="claude-sonnet-5", # change to haiku, opus, or fable
max_tokens=1024,
messages=[{"role": "user", "content": "Explain prompt caching."}],
)What stays the same:
- Tool use / function calling API — same schema, same loop
- Streaming API — same event types and helpers
- Prompt caching headers — same
cache_controlparameters - Context window — all models support 200K tokens
- Vision / multimodal — image inputs work the same way
What changes with the model:
- Quality on hard tasks — Opus pulls ahead on complex reasoning
- Speed — Haiku returns first tokens significantly faster
- Cost — up to 19× difference between Haiku and Opus
- Personality and tone — Fable produces noticeably different creative output
Summary
- Haiku 4.5 (
claude-haiku-4-5-20251001): $0.80/$4 per M tokens — classification, extraction, routing, high-volume pipelines. Use when speed and cost matter more than depth. - Sonnet 5 (
claude-sonnet-5): $3/$15 per M tokens — the safe default for coding, analysis, chat, and automation. Use when you want production quality without Opus cost. - Opus 5 (
claude-opus-5): $15/$75 per M tokens — complex reasoning, long document analysis, orchestration, LLM-as-judge. Use when quality at the edge matters. - Fable 5.1 (
claude-fable-5-1): creative writing, roleplay, narrative applications. Use when the output is fiction, not fact. - Switching models is one line of code — prototype with Sonnet, drop to Haiku if it passes quality checks, upgrade to Opus only where Sonnet falls short.
- Mixing models in one application is a standard pattern: cheap model for routing, expensive model for judgment.
Further reading: Claude API Pricing Explained for deeper cost optimization, Prompt Caching to cut input token costs, and Build an AI Agent with Python for the multi-agent pattern where model mixing is most powerful.
Subscribe to my newsletter — practical guides on Claude API, AI agents, RAG, and automation.