Best Claude Model for Coding

Opus 5, Sonnet 5, Fable 5 or Haiku 4.5 — which Claude model to code with. Real benchmark scores, rate limits, effort levels and API pricing.

Best Claude Model for Coding: Benchmarks, Limits and API Pricing

Picking the best Claude model for coding starts with Anthropic's four model classes, from most to least capable: Fable, then Opus, then Sonnet, then Haiku. The difference between them narrows with each release, and Anthropic offers two strategies for choosing a model — capability-first or efficiency-first — but does not say which one to use for coding specifically. This guide fills that gap with current pricing and benchmark scores for Claude Fable 5, Opus 5, Sonnet 5, and Haiku 4.5, plus the limits worth knowing before you build.

Quick Answer

  • Claude Opus 5 (claude-opus-5) — best for hard agentic coding: multi-file refactors, deep cross-file debugging, and long autonomous runs.
  • Claude Sonnet 5 (claude-sonnet-5) — best everyday default: feature work, routine bug fixes, and interactive coding at $2 / $10 per million tokens.
  • Claude Fable 5 (claude-fable-5) — best for maximum capability: the hardest, longest-horizon tasks, where Opus 5 visibly struggles on your own evals.
  • Claude Haiku 4.5 (claude-haiku-4-5) — best for volume and latency: PR review at scale, classification, routing, and cheap sub-agent steps.

Claude models for coding at a glance

All fifth-generation models from Anthropic — Fable 5, Opus 5, and Sonnet 5 — come with a 1M-token context window out of the box at standard pricing. No extra charge for long context anymore. This is a key difference from the previous Opus 4.x line, where the 1M window was available only as a paid beta add-on. The only exception is Haiku 4.5, which remains capped at 200K tokens. The table below is the fast version of the Claude Opus vs Sonnet vs Fable question.

Model Model ID Released Context Max output Price (in / out per MTok) Best for
Claude Fable 5claude-fable-5Jun 9, 20261M128K$10 / $50Hardest, longest-horizon coding agent runs
Claude Opus 5claude-opus-5Jul 24, 20261M128K$5 / $25Daily-driver flagship coding and agents
Claude Sonnet 5claude-sonnet-5Jun 30, 20261M128K$2 / $10High-volume, latency-sensitive coding
Claude Haiku 4.5claude-haiku-4-5Oct 15, 2025200K64K$1 / $5Sub-agents, free-tier UX

Claude Fable 5

Claude Fable 5 is Anthropic's most capable publicly available coding agent model, announced June 9, 2026 alongside the partner-restricted Claude Mythos 5. Its model ID is claude-fable-5.

Fable and Mythos are two packages of the same underlying model, which is Anthropic's most capable model class with frontier capabilities across coding, long-running agent tasks, and problems AI has not reliably handled before. Claude Mythos is restricted to trusted partners through the Project Glasswinginitiative — organizations operating in cybersecurity and biological research, fields where the knowledge and tools involved can be used for both constructive and destructive purposes. That is why access is strictly controlled and not available to the general public. Claude Fable adds safety classifiers on top of the same model so it can be released for general API access. Both require limited data retention as a condition of that access, so it is worth checking against your own data-handling policy before integrating either one.

Fable 5's safety classifiers can trigger a refusal on cybersecurity and biology requests. Anthropic reports that fallback firing happens in under 5% of sessions, routing to Opus 4.8 when it does. Most teams will never get API access to Mythos 5 and should treat Fable 5 as the practical ceiling for a coding agent.

Benchmarks

Benchmark Score Notes
SWE-bench Verified~95%Third-party aggregators, Aug 2026
SWE-bench Pro (vendor-reported)Tops the boardA few points ahead of Opus 5, just behind Mythos 5

Pricing

Claude Fable 5 pricing:

  • $10 per 1 million input tokens
  • $50 per 1 million output tokens
  • Exactly double Opus 5, with the same 90% prompt-caching discount and 50% batch discount as every other model in this line-up

Best for: the longest-running and hardest coding agent tasks, where the 2x price over Opus 5 is offset by fewer total tokens spent per completed task.

Claude Opus 5

Claude Opus 5 launched July 24, 2026 and is now Anthropic's default model on Claude Max and its strongest option on Claude Pro. Its model ID is claude-opus-5.

Opus is Anthropic's model class for reasoning-intensive enterprise tasks and consistently ranks among the leading models on industry benchmarks such as GDPval-AA for knowledge work and Terminal-Bench 2.1 for agentic coding. The choice between Opus and Fable is not always clear on the surface, since both excel at coding, long-running agents, and knowledge work. In practice, larger models like Fable tend to show more judgment and creativity despite posting similar benchmark scores to Opus. Anthropic's own rule of thumb is that if your evals show Opus struggling on a task, Fable is the answer. If Opus already clears your quality bar, its speed and price make it the better choice.

Opus 5 ships with an effort dial ranging from low to high effort, plus extended and adaptive thinking budgets on supported surfaces, letting a team trade reasoning depth for cost on a per-request basis. It also introduced two beta features at launch: mid-conversation tool changes, which let a running session swap which tools Claude can call without invalidating the prompt cache, and automatic fallbacks, which route a request that Opus 5's safety classifiers flag to another model instead of returning a refusal outright.

Still running Opus 4.8? It remains callable through the API at the same $5/$25 price as Opus 5, but Opus 5 beats it on every benchmark Anthropic has published so far, including SWE-bench and Frontier-Bench. There is no cost reason to stay on 4.8 for new coding work — treat it as a migration candidate, not a parallel option, the same way Claude Opus vs Sonnet decisions default to the newer generation once price parity holds.

Benchmarks

Benchmark Score Notes
Frontier-Bench v0.1More than 2x Opus 4.8's scoreAt a lower cost per task
SWE-bench Pro (vendor-reported)High-70s–low-80s%Just behind Fable 5 and Mythos 5, depending on tracker and eval date
CursorBench 3.2 (max effort)Within 0.5% of Fable 5's peak scoreAt half the cost per task

Pricing

Claude Opus 5 pricing:

  • $5 per 1 million input tokens
  • $25 per 1 million output tokens
  • Unchanged from its predecessor, Opus 4.8

Best for: everyday production coding, multi-file refactoring, and agents, whenever Fable 5's 2x price tag is overkill for the task.

Claude Sonnet 5

Claude Sonnet 5 launched June 30, 2026 as the first model in Anthropic's fifth-generation Sonnet line and is now the default model for Free and Pro users on claude.ai. Its model ID is claude-sonnet-5.

Sonnet is Anthropic's versatile model class for everyday tasks, built to balance performance against cost and speed across the widest range of general-purpose use cases. This includes high-volume sub-agents inside multi-agent orchestration setups, which is exactly the role it plays in most coding pipelines. The model uses an updated tokenizer, and adaptive thinking is enabled by default rather than as an opt-in toggle.

Despite its strong performance in agentic coding, Sonnet 5 was not specifically trained for cybersecurity work. Its real-time safety systems still block certain high-risk dual-use requests before they reach a code-execution tool.

The Claude Opus vs Sonnet decision for a coding agent usually comes down to volume. Opus 5 is better for the smaller share of requests that need the deepest reasoning; Sonnet 5 is better for everything that runs constantly — CI checks, PR review, routine test generation. Both models also carry different knowledge cutoffs worth checking before relying on either for library or framework advice: Sonnet 5's training data runs through January 2026, while Opus 5's runs a few months later, into May 2026.

Benchmarks

Benchmark Score Notes
Terminal-Bench 2.1 (Sonnet 5)80.4%First Sonnet-class model to beat the concurrent Opus flagship on an agentic coding benchmark
Terminal-Bench 2.1 (Opus 4.8)74.6%Sonnet 5 outperforms by 5.8 points
Terminal-Bench 2.1 (Sonnet 4.6)67.0%Sonnet 5 outperforms by 13.4 points
GDPval-AA v2 (knowledge work)1,618 vs Opus 4.8's 1,615Inside the margin of noise

Pricing

Claude Sonnet 5 pricing:

  • $2 per 1 million input tokens
  • $10 per 1 million output tokens
  • Permanent price — the increase originally planned for September 1, 2026 was cancelled

Best for: high-volume agentic coding and multi-file refactors, where near-Opus results at a fraction of the price matter more than the absolute ceiling.

Claude Haiku 4.5

Claude Haiku 4.5 has been Anthropic's fastest model since October 15, 2025. It is the oldest model in this comparison and still current. Its model ID is claude-haiku-4-5.

Haiku is Anthropic's lowest-cost and fastest model class, designed for high-frequency workloads where latency and cost matter more than depth of reasoning.

Haiku 4.5 is the practical choice for coding sub-agents. An orchestrator running on Opus 5 or Fable 5 can delegate narrow, well-specified subtasks to a fleet of Haiku 4.5 workers without paying the more expensive model's rate for routine work — running one test file, applying a scoped diff, or a single code review pass. Haiku 4.5 supports the same tool use, tool calling, and MCP connections as the orchestrator, so a sub-agent is not limited to a narrower toolset just because it runs on a cheaper model.

Benchmarks

Benchmark Score Notes
SWE-bench Verified73.3%Matches Sonnet 4's coding performance at a fraction of the cost

Pricing

Claude Haiku 4.5 pricing:

  • $1 per 1 million input tokens
  • $5 per 1 million output tokens
  • Same prompt-caching and batch discounts as the rest of the line-up

Best for: parallel sub-agents, free-tier products, and latency-sensitive coding tasks that do not need the full 1M context.

The legacy models: should you still use them?

Three older models remain callable but are not where to start new coding work. Claude Opus 4.7 and Claude Opus 4.6 — the latter deprecated May 28, 2026, alongside the Opus 4.8 launch — sit two full generations behind Opus 5 on both price and benchmarks. Claude Sonnet 4.6, released around February 2026, is not formally deprecated and still beats much older models, but Sonnet 5 outscores it on Terminal-Bench 2.1 by 13 points (80.4% vs 67.0%) at a lower price, leaving little reason to stay on it for a new coding agent.

The honest reasons to stay on any of the three are narrow: a pinned, heavily evaluated production prompt you haven't had time to re-validate, a workflow that depends on older extended-thinking behavior, or a compliance process that gates model changes. All three are scheduling problems, not technical ones — nothing about the older models performs a task the newer ones can't.

API rate limits by tier

Anthropic tracks three metrics per organization: requests per minute (RPM), input tokens per minute (ITPM), and output tokens per minute (OTPM). Limits apply separately per model class, so spending down one model's quota doesn't touch another's — Anthropic's own rate-limits documentation specifies that Opus 4.5, 4.6, 4.7, and 4.8 share one combined limit, while Opus 5 gets its own separate bucket; Sonnet 4.5 and 4.6 work the same way against Sonnet 5.

Limits scale automatically with usage tier as cumulative spend crosses a threshold:

Tier Cumulative spend Limits
Tier 1$5 minimumBaseline RPM/ITPM/OTPM
Tier 2$40Higher limits for active development
Tier 3$200Production-level throughput
Tier 4$400 and upHighest standard limits before custom enterprise arrangements

Exceeding any of the three metrics returns an HTTP 429 error with a retry-after header telling a client how long to wait before the next call. Fable 5 and Mythos 5 still run slower than Opus 5 and Sonnet 5 even at the same tier, reflecting their higher per-token cost and more recent rollout. But these numbers change over time — Anthropic regularly updates capacity and limits. Always check the official rate limits page before planning your production setup.

Context window and max output

Fable 5, Opus 5, and Sonnet 5 all default to a 1M-token context window at standard pricing. This is a change from the Opus 4.x generation, where 1M shipped as a separate paid add-on. Haiku 4.5 stays at 200K.

Max output depends on which API mode you use:

Model Context window Max output (sync) Max output (batch)
Fable 5, Opus 5, Sonnet 51M tokens128K tokensup to 300K tokens*
Haiku 4.5200K tokens64K tokensnot supported
Model Context window Max output (sync) Max output (batch)
Fable 5, Opus 5, Sonnet 51M tokens128K tokensup to 300K tokens*
Haiku 4.5200K tokens64K tokensnot supported

* Via the output-300k-2026-03-24 beta header, also available on Opus 4.8, Opus 4.7, Opus 4.6, and Sonnet 4.6. Response turnaround up to 24 hours.

The Batch API gives a 50% discount on all tokens compared to standard pricing. You send a large batch of requests at once (up to 100,000 requests) and get responses within 24 hours — ideal for non-urgent workloads like document processing, data generation, or overnight code analysis.

Claude Code and subscription quotas

Claude Code draws from the same usage pool as the web chat and desktop app under a Claude Pro, Max, Team, or Enterprise subscription. The terminal does not have a separate allowance.

Usage is metered in two ways. First, a rolling five-hour window that starts when you send the first message. Second, a weekly cap that sits on top of that window. The five-hour window tracks active model hours and resets five hours after the first request. The weekly cap is tied to your account and resets at a fixed time. Check current limits with the /usage command inside Claude Code.

Sonnet and Opus share a single pool on the Pro plan, so a long session with Opus can eat into the Sonnet allowance for the rest of the window. On Max plans, they draw from separate five-hour and weekly buckets. Anthropic publishes plan capacity as multipliers rather than fixed hours — Max 5x and Max 20x scale proportionally from the Pro baseline — and does not commit to exact token or hour counts, so treat any source with precise weekly-hour figures as a rough guide, not a guarantee.

Fable 5 does not have a separate bucket inside a subscription. On Max plans and premium Team or Enterprise seats, it draws against the same weekly allowance as every other model, capped at 50% of it. A session with Fable 5 also counts roughly twice as much against that cap as a session with Opus.

Opus 5 and Sonnet 5 default to high effort on both the API and in Claude Code — Anthropic's own setting. High effort burns through a weekly quota noticeably faster than low or medium, because extended thinking tokens are billed like output tokens. Adjust the effort level mid-session with /effort, choosing between low, medium, or high.

Claude Code also ships a built-in way to apply the plan-cheap/execute-cheap pattern automatically: the opusplan model alias uses Opus for reasoning and architecture decisions in Plan Mode, then switches to Sonnet once a plan is approved and execution starts.

Connecting an Anthropic API key switches Claude Code to pay-as-you-go billing instead of the flat subscription limits, bypassing the five-hour and weekly caps entirely — a good choice for CI, automation, or any workload that runs on a schedule rather than inside a person's session.

/compact summarizes a long conversation instead of carrying the full history forward, freeing up context without losing the working state. Claude Code also reads a CLAUDE.md file from the repository root on every call — Anthropic recommends keeping it under roughly 200 lines, since every line counts against input tokens on each request, whether the active session is a full orchestrator or a single delegated sub-agent.

Claude API pricing for coding workloads

Claude API pricing for coding workloads comes down to two levers: how many tokens a task needs to finish, and how much each token costs once caching and batching are accounted for.

Cost per task vs cost per token

The price per token is not what a coding task costs. What matters is total token consumption from start to finish, and that number varies significantly by model.

Consider Sonnet 5 versus Opus 4.8. According to independent benchmarking from Artificial Analysis, an average task on Sonnet 5 costs $2.29, compared to $1.97 for the same task on Opus 4.8 — despite Opus 4.8 costing more than double per token. Sonnet 5 uses more tokens to get there for two reasons: an updated tokenizer that splits the same text into roughly 30% more tokens, and more agentic behavior on hard tasks — extra reasoning steps and intermediate output before arriving at a final answer.

Anthropic's own figures on Claude Code usage confirm the wide variation: average cost runs about $6 per developer per day, with 90% of users under $12 per day. A quiet debugging session and a long autonomous refactor draw from the same per-token pricing but consume very different volumes.

The practical takeaway: measure the actual cost per completed task on your own workloads before committing to a model, and re-measure after any switch — token consumption patterns change between generations, so a comparison based on per-token prices alone can point in the wrong direction.

How to reduce costs with routing

Three mechanisms lower real costs without changing which model does the work.

  1. Prompt caching reuses stable parts of a request instead of reprocessing them on every call. A cache read costs 10% of standard input pricing, while a 5-minute cache write costs 125% and pays for itself after a single reuse; a 1-hour write costs 200% and needs two hits to break even. For a coding agent with a 50,000-token system prompt running 20 requests in a session, caching drops the system prompt cost from roughly $3.00 to $0.47.
  2. Batch processing cuts input and output pricing by 50% for work that does not need an immediate response. Requests run asynchronously and can take up to 24 hours, though most finish within one. The batch discount stacks with prompt caching: a cached, batched request on Opus 4.8 drops from $5 per million input tokens to $0.25 — a 95% reduction.
  3. Task routing sends simple, high-volume work to cheaper models and reserves capable models for tasks that need them. The opusplan model alias in Claude Code is a built-in implementation of this pattern: Opus handles planning and architecture decisions, then execution automatically switches to Sonnet once the plan is approved. The same principle applies to context compaction — /compactsummarizes long conversations instead of carrying the full history forward, lowering the input-token cost of every subsequent turn.

How to run any Claude model through AI/ML API

AI/ML API exposes Claude Fable 5, Opus 5, Sonnet 5, Haiku 4.5, and the older Claude models behind a single OpenAI-compatible endpoint. Every model shares the same interface for tool calling and MCP, so switching between them is a one-line model-name change rather than a new SDK integration:

curl https://api.aimlapi.com/v1/chat/completions \
  -H "Authorization: Bearer $AIMLAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5",
    "messages": [
      {"role": "user", "content": "Refactor this function for readability."}
    ]
  }'

Swap the model value for claude-sonnet-5, claude-fable-5, or claude-haiku-4-5 to route the same request to a different coding model without touching the rest of the integration. See the AI/ML API documentation for authentication, streaming behavior, and tool-calling parameters shared across the whole Claude line-up.

FAQ

What is the best Claude model for coding in 2026?
Claude Opus 5 is the best all-around choice — Anthropic's flagship since July 24, 2026, built for hard agentic coding. Choose Sonnet 5 for high-volume, everyday work at $2/$10 per million tokens, Fable 5 for the hardest long-horizon tasks, and Haiku 4.5 for fast, cheap sub-agents.

Should I use Opus 5 or Sonnet 5 for coding?
Use Opus 5 for the smaller share of requests that need the deepest reasoning — multi-file refactors, deep debugging. Use Sonnet 5 for everything that runs constantly: CI checks, PR review, routine test generation. Both share a 1M-token context window; Sonnet 5 costs a fraction of Opus 5's price.

Which Claude model should I use in Claude Code?
Default to Sonnet 5 for routine work and switch to Opus 5 for hard, multi-step problems — or use the built-in opusplan alias, which plans with Opus and executes with Sonnet automatically. Reserve Fable 5 for the longest, hardest agentic runs, since it draws double the weekly quota of an Opus session.

What effort level should I use for coding on Claude Opus 5?
Opus 5 defaults to high effort on both the API and in Claude Code — Anthropic's own setting. Use high for routine coding and step up only for genuinely hard debugging or multi-step problems, since higher effort spends more extended-thinking tokens, which bill like output tokens.

Does Fable 5 code better than Opus 5?
On vendor-reported SWE-bench Pro scores, Fable 5 and Opus 5 sit within a few points of each other, with Fable 5 slightly ahead. Fable 5 costs twice as much per token and draws roughly double the weekly Claude Code quota of an Opus session — reserve it for the longest, hardest agentic tasks.

Is Claude Opus 4.8 still worth using?
Not for new work. Opus 4.8 costs the same as Opus 5 ($5/$25 per million tokens) but scores lower on every benchmark Anthropic has published, including Frontier-Bench v0.1. It remains callable through the API, so existing integrations keep working, but there's no price reason to start a new project on it.

How do I switch models in Claude Code?
Run /model inside a session to see and switch the active model, or use the opusplan alias to let Opus plan and Sonnet execute automatically. /effort adjusts reasoning depth independently, and /usageshows how much of your weekly quota remains before you switch to a pricier model.

Which benchmark should I trust for Claude coding models?
Match the leaderboard, not just the benchmark's name. SWE-bench Pro has two active leaderboards — Scale AI's standardized public set, which scores much lower, and vendor-reported tables — that aren't directly comparable. Confirm both models were scored on the same leaderboard before comparing them.

How do I cut the cost of Claude coding workloads?
Combine prompt caching (up to 90% off repeated input via cache reads), the Batch API (50% off async work, stacking with caching for up to 95% off), and task routing: plan on Opus 5, execute routine work on Sonnet 5 or Haiku 4.5, and reserve Fable 5 for tasks that repeatedly fail on cheaper models.

What is the best Claude model for coding for free?
Sonnet 5 is the default for free users on claude.ai, priced for high-volume use at $2/$10 per million tokens via the API. Haiku 4.5 is cheaper still at $1/$5 and is what most free-tier products build sub-agents on.

Key Takeaways

  • Claude Opus 5 (July 24, 2026) is Anthropic's current coding flagship at $5/$25 per million tokens — the same price as Opus 4.8, with higher benchmarks across the board.
  • Claude Sonnet 5 costs $2/$10 per million tokens, permanently — the price increase originally planned for September was cancelled.
  • Claude Fable 5 ($10/$50) leads on the hardest agentic tasks but draws roughly double the weekly Claude Code quota of an Opus session, capped at 50% of the total allowance.
  • Claude Haiku 4.5 is the only model here capped at 200K context; every Claude 5-generation model ships 1M tokens by default.
  • Prompt caching, batching, and effort-level routing can be stacked for up to a 95% cost reduction — cost per token rarely equals cost per task.
  • SWE-bench Pro scores vary sharply by leaderboard methodology — compare models only when their scores come from the same source.

Share with friends

Ready to get started? Get Your API Key Now!

Get API Key