NewKimi K3.1 Pro is now availableTry it now
GuidePublished 7 min read

Best Claude Model for Coding: A Task-by-Task Decision Guide

Sonnet 5 is the right default for most coding. Switch to Opus 5 for hard tasks and Haiku 4.5 for volume — with current pricing and a local test.

Inference.net

The best Claude model for coding depends on the task — start with Sonnet 5

For ordinary coding work, default to Sonnet 5. It is fast, permanently priced at $2/$10 per million input/output tokens since 2026-08-10 (not an introductory rate), and gives a 1M-token context window. Switch up to Opus 5 ($5/$25) when a task is genuinely hard or long-running: multi-file refactors, debugging that crosses layers, or work against fast-moving frameworks where its May 2026 knowledge cutoff matters. Switch down to Haiku 4.5 ($1/$5) for bounded, checkable, high-volume steps. Fable 5 is almost never the right coding spend (details below).

Coding taskRecommendation
Ordinary day-to-day codingSonnet 5
Genuinely hard or long-runningOpus 5
Bounded, checkable, high-volumeHaiku 4.5
"It didn't try hard enough" failsRaise effort — don't switch model

Basis: Anthropic's model-selection guidance, internal cost/intelligence sweeps, the Claude Code team's model-vs-effort heuristic, and Haiku 4.5 agentic-coding results. Verified 2026-08-26.

This guide covers coding only; the broader "best Claude model" decision weighs the same menu differently.

The current Claude lineup and what it costs (August 2026)

Four current models matter for coding; API IDs, prices, context windows, effort support, and knowledge cutoffs are below.

Models, API IDs, and pricing

ModelAPI IDInput ($/MTok)Output ($/MTok)
Haiku 4.5claude-haiku-4-5-20251001$1$5
Sonnet 5claude-sonnet-5$2$10
Opus 5claude-opus-5$5$25
Fable 5claude-fable-5$10$50

Context, output, effort, and knowledge cutoff

ModelContextMax outputEffort paramCutoff
Haiku 4.5200K64KNoFeb 2025
Sonnet 51M128KYesJan 2026
Opus 51M128KYesMay 2026
Fable 51M128KYesJan 2026

All figures from Anthropic's models overview and pricing page, verified 2026-08-26. Sonnet 5's $2/$10 launched as introductory pricing; per the 2026-08-10 edit to the announcement it is permanent — the scheduled 2026-09-01 rise to $3/$15 will not occur. Haiku 4.5 supports extended thinking only; the other three support adaptive thinking with an effort parameter, default high.

Did it not know enough, or not try hard enough?

Model choice and reasoning effort are two separate controls. Reasoning effort is how much work the model does per turn — how many files it reads, how many tool calls it makes, whether it verifies before reporting back. The model sets the capability ceiling; effort sets thoroughness.

Anthropic's Claude Code team's heuristic: if Claude had the context, clearly tried, and still got it wrong, the task outgrew the model — switch models. If it skipped a file, never ran the tests, or bailed partway, it did not try hard enough — raise effort instead. Effort has five levels (low, medium, high, xhigh, max) and defaults to high; changing it mid-conversation invalidates the prompt cache, so set it at session start.

Migrating from Opus 4.7 or 4.8? Do not carry old effort settings over: their recommended coding start was xhigh; on Opus 5 it is the default high. Re-run a fresh effort sweep and delete "verify twice" prompt text — Opus 5 self-verifies, and Anthropic measured stale 4.8-era prompts costing 36% more per ticket.

When to switch up to Opus 5 (and why Fable 5 is rarely the answer)

Anthropic's own positioning starts complex agentic coding — work where the model runs a loop of reading files, calling tools, running tests, and editing over many turns — on Opus 5. Signals a task has outgrown Sonnet 5:

  • A refactor spanning many files or layers, where a wrong early assumption compounds.
  • Debugging where cause and symptom sit in different layers.
  • Long-running agent sessions where Sonnet 5 keeps re-deriving context or abandoning subtasks.
  • Work against a fast-moving framework — Opus 5's cutoff is May 2026 versus January 2026 for Sonnet 5 and Fable 5, so it is less likely to hallucinate deprecated APIs.

The premium is real: Opus 5 runs $5/$25 against Sonnet 5's $2/$10 — the same price as Opus 4.8, whose retirement horizon runs into 2027 — and Anthropic rates its latency moderate versus fast. Most "I need Opus" moments are "didn't try hard enough" moments that higher effort fixes for less money.

Fable 5 is the capability ceiling, not the coding default. On Anthropic's internal 482-problem SWE-bench Pro subset (selected for harness compatibility, not comparable to the public leaderboard), Opus 5 scored 91.7% versus Fable 5's 91.3% — inside run-to-run noise — at about 60% of the cost. Anthropic publishes no SWE-bench Verified or Pro leaderboard numbers for Opus 5; treat third-party percentages as unverified. Access friction too: Fable 5 is never the Claude Code default, and safety classifiers reroute some flagged requests to Opus models mid-session. Unless you have measured a task Opus 5 at xhigh cannot do, skip it.

When a cheaper or faster model is enough

Haiku 4.5 is the fastest and cheapest current model at $1/$5; Anthropic positions it as the starting point for high-volume, latency-sensitive work and sub-agent tasks. It fits steps with a cheap, automatic check — a script you will run, a test you will execute, a diff you will review. It has no effort parameter (extended thinking only); vendor-reported figures put it near 90% of Sonnet 4.5 on an agentic coding evaluation but much further behind on long tasks — keep it off long-running loops.

Or keep Sonnet 5 and step effort down: in Anthropic's internal sweeps, medium on long-running coding work gave up about 2 points for half the cost; Sonnet 5 at medium is comparable to Sonnet 4.6 at high, and low suits high-volume, latency-sensitive work. Budgeting caveat: Claude 4.7+ models use a newer tokenizer emitting roughly 30% more tokens for the same text — recount usage before comparing costs across generations.

Where the choice happens in Claude Code

Claude Code resolves default to Opus 5 on Max, Team Premium, Enterprise pay-as-you-go, and API accounts, and to Sonnet 5 on Pro and Team Standard. Switching is a one-line change, with version floors — Opus 5 needs Claude Code v2.1.219+, Sonnet 5 v2.1.197+:

bash
# --- Switch the model mid-session (inside Claude Code) ---
# Saved as your default since Claude Code v2.1.153.
> /model claude-opus-5
> /model claude-sonnet-5

# --- Switch the model at launch (from your shell) ---
claude --model claude-opus-5
claude --model claude-sonnet-5

# Or via environment variable:
#   export ANTHROPIC_MODEL=claude-opus-5

# --- Set reasoning effort ---
# low | medium | high | xhigh | max
# Default is high on every effort-capable model except Opus 4.7 (xhigh).
# low/medium/high/xhigh persist across sessions; max is session-only
# unless set via CLAUDE_CODE_EFFORT_LEVEL.
> /effort high
claude --effort xhigh

# --- Version floors ---
#   Opus 5    requires Claude Code v2.1.219+
#   Sonnet 5  requires Claude Code v2.1.197+
#   Fable 5   requires Claude Code v2.1.170+
# Check your version with: claude --version

/effort and --effort settings persist across sessions, except session-only max. For the local test below, pin full model IDs (or set ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_SONNET_MODEL): aliases like sonnet and opus resolve per provider and drift over time.

This page does not cover Claude plan limits or Claude Code slowness.

Still not sure? Run a small test on your own tasks

When the Sonnet 5 versus Opus 5 call is close, no benchmark settles it — your workload does. Anthropic's own method for weighing cost against intelligence, scaled to one developer (it baselines across effort levels, not just defaults):

  1. Pull three to five real tasks from recent work — tickets or commits, not toy prompts.
  2. Run each candidate on the same tasks in the same coding agent at default effort; record pass or fail.
  3. Record tokens and latency for each run alongside the verdict.
  4. Compare cost per completed task, not per token — a more capable model often finishes in fewer turns, and a failed cheap attempt still bills its tokens plus the retry.

To run this without touching your Anthropic subscription: route Claude Code to a selected, separately billed catalog model through Inference.net (fast claude on --model <catalog-id> maps Claude Code's model slots to one catalog model; fast claude off restores your settings), then verify per-model tokens and spend in the usage dashboard. It bills a separate Inference.net balance — no added Anthropic plan quota, no speedup to an unchanged Anthropic model. Setup mechanics live on the Claude Code integration docs.

Step-by-step setup: Claude Code integration docs.

Related reading & models

Back to all guides