Originally published at kalyna.pro
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. 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 Haiku handles just as well at a fraction of the cost.
The Claude 5 Family at a Glance
| Model | API ID | Best For | Input $/M | Output $/M |
|---|---|---|---|---|
| Haiku 4.5 | claude-haiku-4-5-20251001 |
High-volume, low-latency | $0.80 | $4 |
| Sonnet 5 | claude-sonnet-5 |
Coding, analysis, everyday | $3 | $15 |
| Opus 5 | claude-opus-5 |
Complex reasoning, research | $15 | $75 |
| Fable 5.1 | claude-fable-5-1 |
Creative writing, roleplay | varies | varies |
All four share a 200K context window and the same API contract.
Haiku 4.5 — Fast, Cheap, Built for Scale
claude-haiku-4-5-20251001 — $0.80/M input, $4/M output
Best for: classification, data extraction, high-volume pipelines, agent sub-tasks.
from anthropic import Anthropic
client = Anthropic()
def classify_support_ticket(ticket_text: str) -> str:
response = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=20,
system="Classify into: 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) # → billing
Haiku falls short on: multi-step reasoning chains, nuanced writing, tasks where wrong answers have real consequences.
Sonnet 5 — The Everyday Workhorse
claude-sonnet-5 — $3/M input, $15/M output
The model most developers should use by default. Best for: code generation, analysis, multi-turn conversations, document processing, RAG pipelines.
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:
{language}
{code}
}
],
)
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,))
Opus 5 — Maximum Capability
claude-opus-5 — $15/M input, $75/M output
Use when: complex multi-step reasoning, long document analysis, research, agent orchestration, LLM-as-judge evaluation.
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 for: unusual clauses, "
"missing protections, liability risks, and ambiguous language."
),
messages=[{"role": "user", "content": f"Analyze this contract:
{contract_text}"}],
)
return response.content[0].text
print(analyze_contract(open("vendor_agreement.txt").read()))
Rule: if Sonnet gives identical results for your use case (most coding, basic analysis, chatbots), Opus is wasted money.
Fable 5.1 — The Creative Model
claude-fable-5-1 — specialist model for creative and narrative tasks.
Best for: interactive fiction, roleplay, creative writing, story-driven applications.
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.",
messages=[{"role": "user", "content": f"Write an opening scene: {premise}"}],
)
return response.content[0].text
For business tasks — analysis, code, data extraction — stick to Haiku/Sonnet/Opus.
How to Choose the Right Model
- Latency and cost matter more than quality → Haiku 4.5
- Routine coding, analysis, or chat → Sonnet 5
- Hard reasoning, long documents, quality-critical output → Opus 5
- Creative writing or character roleplay → Fable 5.1
When in doubt: prototype with Sonnet. Drop to Haiku if quality holds. Upgrade to Opus only where Sonnet falls short.
Mixing Models in Production
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 intent as one 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
if intent in ("technical", "refund"):
model = "claude-sonnet-5"
system = "You are a technical support engineer."
else:
model = "claude-haiku-4-5-20251001"
system = "You are a friendly support agent."
final = client.messages.create(
model=model,
max_tokens=512,
system=system,
messages=[{"role": "user", "content": user_query}],
)
return final.content[0].text
Summary
-
Haiku 4.5 (
claude-haiku-4-5-20251001): $0.80/$4/M — classification, extraction, high-volume -
Sonnet 5 (
claude-sonnet-5): $3/$15/M — the safe default for most production tasks -
Opus 5 (
claude-opus-5): $15/$75/M — complex reasoning, long docs, orchestration -
Fable 5.1 (
claude-fable-5-1): creative writing, roleplay, narrative - Switching models is one line of code — API contract is identical
- Mix models in one app: cheap routing + expensive judgment = best cost/quality ratio
Further reading:
Top comments (0)