Cost, Billing, and OpsOctober 11, 2026Flatkey Team

Which Claude Model Is Best for Coding? Opus 5.5 vs Sonnet 5.5 vs Haiku 5.5 vs Fable 5.1 (2026)

Which Claude model should you use for coding in 2026? A task-by-task guide to Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1, with official pricing, session cost math, Claude Code aliases and runnable API examples.

Which Claude Model Is Best for Coding? Opus 5.5 vs Sonnet 5.5 vs Haiku 5.5 vs Fable 5.1 (2026)

Which Claude Model Is Best for Coding? Opus 5.5 vs Sonnet 5.5 vs Haiku 5.5 vs Fable 5.1 (2026)

For most coding work in October 2026, Claude Opus 5.5 is the best Claude model to start with: Anthropic recommends it as the default for "long-running agentic coding," it has a 1M-token context window, and at $4 / $20 per million input/output tokens it costs less than older Opus models. Use Claude Sonnet 5.5 ($2 / $10) for everyday code generation and high-volume agent loops, Claude Haiku 5.5 (from $0.10 / $0.50) for sub-agents, linting, and routing, and Claude Fable 5.1 ($10 / $50) only when Opus 5.5 at high effort still fails your evals on multi-hour tasks. All prices and specs below come from Anthropic's official models overview and pricing page, checked October 27, 2026.

This guide is for developers who run coding agents (Claude Code, Cline, Cursor, OpenCode, or their own agent on the Messages API) and have to pick a model per task, not once for everything. It covers the current lineup, a task-by-task decision table, how Claude Code's model aliases and opusplan work, effort settings, the real cost of a coding session, and copy-paste code. If you only need the full Claude rate card, see our Claude API pricing guide.

The Claude coding lineup in October 2026

Anthropic's current generation has four models. All four support text and image input, tool use, and a 1M-token context window with up to 128K output tokens, according to the models overview (checked October 27, 2026).

Model API ID Anthropic's positioning Input / output per 1M tokens Cache read per 1M Default effort Context / max output
Claude Fable 5.1 claude-fable-5-1 Demanding reasoning and long-horizon agentic work $10 / $50 $0.25 high 1M / 128K
Claude Opus 5.5 claude-opus-5-5 Long-running agentic coding and knowledge work $4 / $20 $0.20 medium 1M / 128K
Claude Sonnet 5.5 claude-sonnet-5-5 Best combination of speed and intelligence $2 / $10 $0.10 high 1M / 128K
Claude Haiku 5.5 claude-haiku-5-5 High-volume, latency-sensitive tasks $0.10 / $0.50 (prompts ≤100K tokens); $0.50 / $2.50 above 100K $0.01 medium 1M / 128K

Sources: Anthropic models overview and Anthropic pricing, October 27, 2026.

Three details in that table change how you should choose:

  1. Opus got cheaper. Opus 5.5 is $4 / $20, while Opus 5, Opus 4.8, and earlier Opus models are still listed at $5 / $25 on the pricing page. If you pinned an older Opus snapshot for coding, moving to Opus 5.5 lowers the per-token price and gets you the newer model.
  2. Cache reads are very cheap on the 5.5 models. Anthropic charges 5% of the base input price for cache hits on Opus 5.5 and Sonnet 5.5, and 2.5% on Fable 5.1 (October 27, 2026). Coding agents resend the same system prompt, tool definitions, and file context on every turn, so caching matters more than the headline input price.
  3. Haiku 5.5 has a price step at 100K tokens. It is the only current model with long-context pricing. Above 100K prompt tokens the input price rises from $0.10 to $0.50 per million. A Haiku sub-agent that reads a whole repository can cost five times more per input token than one that reads a few files.

Which Claude model is best for coding? Decide by task

Anthropic's choosing-a-model guide says most workloads should start with Opus 5.5, move up to Fable 5.1 when evals at higher effort still fall short, and use Sonnet 5.5 for "everyday coding, agent, and enterprise workloads." Applied to real coding jobs, that gives this map:

Coding task Start with Why Move to if it fails
Multi-file refactor, framework migration, multi-hour autonomous agent Opus 5.5 Anthropic's recommended model for long-running agentic coding Fable 5.1
Feature work in a known codebase, writing tests, code review comments Sonnet 5.5 Half the Opus price, high default effort, fast Opus 5.5
Plan a change, then execute it Opus 5.5 plans, Sonnet 5.5 executes (opusplan in Claude Code) Pay Opus rates only for the reasoning-heavy part Opus 5.5 for both
Sub-agents: grep, summarize files, classify errors, triage CI logs Haiku 5.5 Fastest and cheapest current model Sonnet 5.5
Hard debugging where the agent loops or gives up Opus 5.5 at higher effort Raising effort is often a better lever than switching models Fable 5.1
Research-grade work, hours-long sessions that must verify themselves Fable 5.1 Anthropic's most capable model open to all customers Split the task
Autocomplete-style edits, docstrings, commit messages Haiku 5.5 or Sonnet 5.5 Low latency matters more than depth Sonnet 5.5

Short version: Opus 5.5 is the best default, Sonnet 5.5 is the best value, Haiku 5.5 is the best helper, and Fable 5.1 is the specialist you call when the others run out of road.

Opus 5.5 vs Sonnet 5.5 for coding

This is the decision most teams actually face. Opus 5.5 costs twice as much per token as Sonnet 5.5 on input, output, and cache reads. The question is whether it finishes tasks in fewer turns. In practice:

  • Choose Opus 5.5 when a task needs the model to hold a plan across many files and many tool calls, when a wrong step is expensive (database migrations, auth code, concurrency), or when Sonnet keeps asking for clarification or stopping early.
  • Choose Sonnet 5.5 when tasks are well scoped (one ticket, one module), when you run many agents in parallel, or when latency matters to a developer waiting at the terminal.
  • Measure cost per finished task, not cost per token. If Sonnet needs three attempts where Opus needs one, Sonnet is not cheaper. Run 20 to 30 of your own real tickets through both and compare total tokens and pass rate. Do not choose from someone else's benchmark table.

When Fable 5.1 is worth it

Fable 5.1 is 2.5 times the Opus 5.5 price on input and output. Anthropic's guidance is to use it "when your evals on Claude Opus 5.5 at higher effort still fall short" (models overview). For coding, that usually means very long autonomous sessions, large codebase investigations, or work where the agent must check its own results before it reports back. Note two limits from the Claude Code model configuration docs: Fable is never the default model on any plan, and requests that its safety classifiers flag, most often in cybersecurity and biology topics, trigger automatic fallback to another model. On some plans Fable usage bills to usage credits instead of included limits.

Where Haiku 5.5 fits

Haiku 5.5 is not a toy model. Anthropic suggests an "efficiency-first" approach of starting with Haiku 5.5 for prototyping, tight latency budgets, and high-volume tasks, then upgrading only where you see gaps (choosing a model). In a coding agent it is the right model for the work around the code: reading logs, picking which files to open, summarizing diffs, and labeling issues. Keep its prompts under 100K tokens when you can, because of the price step described above.

Effort: the setting that matters more than the model name

All current Claude models use adaptive thinking, and Anthropic exposes an effort parameter that trades intelligence for latency and cost within one model. The choosing-a-model guide says tuning effort "is often a better lever than switching models." Defaults as of October 27, 2026:

Model Default effort Practical coding advice
Fable 5.1 high Lower effort for routine steps inside a long session
Opus 5.5 medium Raise to high for hard debugging before you switch to Fable
Sonnet 5.5 high Drop to medium for simple edits to cut latency
Haiku 5.5 medium Keep low or medium for sub-agent chores
Opus 4.8 / 4.7 (legacy) n/a Anthropic says xhigh is best for most coding on these

A useful rule: if Opus 5.5 at medium fails a task, try Opus 5.5 at high before paying for Fable 5.1. If Sonnet 5.5 at high fails, try Opus 5.5 at medium before raising Sonnet further.

Which model does Claude Code use, and how do you change it?

Claude Code picks a model through aliases. According to the model configuration docs (checked October 27, 2026), on the Anthropic API the opus, sonnet, and haiku aliases resolve to Opus 5.5, Sonnet 5.5, and Haiku 5.5. On other providers they can resolve to older versions:

Provider opus sonnet haiku
Anthropic API Opus 5.5 Sonnet 5.5 Haiku 5.5
Claude Platform on AWS Opus 5.5 Sonnet 4.6 Haiku 4.5
Amazon Bedrock, Google Cloud Opus 5.5 Sonnet 4.5 Haiku 4.5
Microsoft Foundry Opus 4.6 Sonnet 4.5 Haiku 4.5

Source: Claude Code model configuration, October 27, 2026.

That table explains a common complaint that "Sonnet feels worse in my company's setup." The alias may point to an older Sonnet on your provider. Pin the full model ID to be sure.

Other useful aliases from the same page:

  • fable: uses Fable 5.1 for the hardest, longest tasks.
  • best: uses Fable where it is available to you, otherwise Opus.
  • opusplan: uses Opus in plan mode, then switches to Sonnet for execution. For many teams this is the best cost and quality mix.
  • sonnet[1m]: forces the 1M window on older Sonnet versions. It has no effect on Sonnet 5.5, which already has 1M context.

Ways to set the model:

# For one session
claude --model opusplan

# Inside a session
/model sonnet

# Pin an exact version for every session started from this shell
export ANTHROPIC_MODEL=claude-opus-5-5

# Make sub-agents that inherit "sonnet" use the newest Sonnet on a provider whose alias lags
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5-5

Claude Code also enforces minimum versions: Opus 5.5 needs v2.1.280 or later, Sonnet 5.5 needs v2.1.284 or later, and Haiku 5.5 needs v2.1.293 or later. Run claude update if a model request fails (model configuration).

What a coding session actually costs

Anthropic's pricing page gives a worked example: a one-hour Opus 5.5 coding session with 50,000 input tokens and 15,000 output tokens. Here is the same session on each model at list price (October 27, 2026), with and without caching 40,000 of the input tokens:

Model No cache With 40K cached input tokens
Fable 5.1 50K × $10 + 15K × $50 = $1.25 $0.10 + $0.01 + $0.75 = $0.86
Opus 5.5 50K × $4 + 15K × $20 = $0.50 $0.04 + $0.008 + $0.30 = $0.348
Sonnet 5.5 50K × $2 + 15K × $10 = $0.25 $0.02 + $0.004 + $0.15 = $0.174
Haiku 5.5 50K × $0.10 + 15K × $0.50 = $0.0125 $0.001 + $0.0004 + $0.0075 = $0.0089

Cache writes are billed at 1.25 times the input price for 5-minute caching and 2 times for 1-hour caching, so the cached column assumes the write happened on an earlier request. Real agent sessions are usually much larger than this example because every turn resends tool definitions and file context, which makes caching even more valuable. Our prompt caching ROI guide shows how to measure the hit rate.

Two more price levers for coding:

  • Fast mode gives up to 2.5 times higher output speed at premium prices, $8 / $40 per million tokens for Opus 5.5 (pricing, October 27, 2026). Use it for interactive pair-programming, not for background agents.
  • Batch API gives a 50% discount on input and output. It suits overnight jobs such as generating tests for a whole module or reviewing many pull requests, but it is not available with fast mode.

Call each Claude model from code

The examples below use the official Anthropic API. To run the same code through Flatkey, change only the base URL and key, as described in the Flatkey Anthropic SDK guide. Flatkey's Claude model pages listed Claude Opus 5.5 at $3.20 / $16 and Sonnet 5.5 at $1.60 / $8 per million tokens on October 27, 2026, which is 20% below Anthropic's list price.

curl

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 2048,
    "messages": [
      {"role": "user", "content": "Refactor this function to remove the N+1 query:\n\ndef load(users):\n    return [db.get_orders(u.id) for u in users]"}
    ]
  }'

Python: route by task type

import os
from anthropic import Anthropic

# Direct: Anthropic()  |  Through Flatkey: set base_url and a Flatkey key
client = Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    base_url=os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com"),
)

MODEL_FOR_TASK = {
    "refactor": "claude-opus-5-5",
    "feature": "claude-sonnet-5-5",
    "review": "claude-sonnet-5-5",
    "triage": "claude-haiku-5-5",
    "hard": "claude-fable-5-1",
}

def run(task_type: str, prompt: str) -> str:
    model = MODEL_FOR_TASK.get(task_type, "claude-sonnet-5-5")
    msg = client.messages.create(
        model=model,
        max_tokens=4096,
        messages=[{"role": "user", "content": prompt}],
    )
    u = msg.usage
    print(f"{model}: in={u.input_tokens} out={u.output_tokens} "
          f"cache_read={getattr(u, 'cache_read_input_tokens', 0)}")
    return "".join(b.text for b in msg.content if b.type == "text")

print(run("triage", "Classify this CI error: ModuleNotFoundError: No module named 'pydantic_core'"))

Node.js

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
  baseURL: process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com",
});

const msg = await client.messages.create({
  model: "claude-sonnet-5-5",
  max_tokens: 2048,
  messages: [{ role: "user", content: "Write Jest tests for a slugify(str) function." }],
});

console.log(msg.content.filter((b) => b.type === "text").map((b) => b.text).join(""));
console.log(msg.usage);

Claude Code through Flatkey

Flatkey's Claude Code guide uses two environment variables. Note that the base URL has no trailing /v1:

export ANTHROPIC_BASE_URL="https://router.flatkey.ai"
export ANTHROPIC_API_KEY="sk-fk-your-flatkey-key"
claude --model opusplan

After a test request, check the model ID, token counts, and cost in the Flatkey console usage logs. For more setup detail, see Claude Code API router setup and CC Switch with Flatkey.

Older Claude models: should you still use them?

Anthropic still lists Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 4.6, and Haiku 4.5 on its pricing page. For coding there is little reason to stay on them:

  • Opus 4.x and Opus 5 cost $5 / $25, more than Opus 5.5 at $4 / $20.
  • Sonnet 4.6 costs $3 / $15, more than Sonnet 5.5 at $2 / $10.
  • Haiku 4.5 costs $1 / $5 and has a 200K context window. Haiku 5.5 costs $0.10 / $0.50 for prompts up to 100K tokens and has a 1M window.

The main reason to stay is a pinned production prompt you have not re-tested. If you use a provider where Claude Code's sonnet alias still points to Sonnet 4.5 or 4.6, you are paying more for an older model without knowing it. Check the alias table above, and plan migrations before the retirement dates on Anthropic's model deprecations page.

How to test your choice in one afternoon

  1. Pick 20 to 30 real tasks from your backlog: a mix of bug fixes, small features, refactors, and test writing.
  2. Write a pass condition for each: tests pass, lint is clean, the diff is under a set size.
  3. Run each task on Sonnet 5.5 (high effort) and Opus 5.5 (medium effort). Add Fable 5.1 only for the tasks both fail.
  4. Record total input, output, and cached tokens per task from the usage object, and multiply by the official rates.
  5. Choose the cheapest model whose pass rate meets your bar for each task type. Write that into the routing table in your agent config.

This takes a few hours and gives a better answer than any public leaderboard, because it measures your code, prompts, and tools. Our best LLMs for coding guide compares Claude with GPT, Gemini, and open-weight models using the same method.

FAQ

Which Claude model is best for coding?

Claude Opus 5.5 is the best default for coding as of October 2026. Anthropic recommends it for long-running agentic coding, it has a 1M-token context window, and it costs $4 / $20 per million tokens. Use Sonnet 5.5 for everyday coding at half the price, and Fable 5.1 only when Opus 5.5 at higher effort fails.

What Claude model is best for Claude Code?

On the Anthropic API, opusplan (Opus 5.5 for planning, Sonnet 5.5 for execution) is a strong default for cost and quality. Use opus for large refactors and long autonomous runs, and haiku for sub-agents. Check which version each alias resolves to on your provider in the model configuration docs.

Which Claude mode is best for coding?

Plan mode with opusplan works well for multi-step changes because the plan is made by the stronger model. For hard bugs, raise the effort level before switching models. Fast mode suits interactive work where speed matters and you accept premium pricing ($8 / $40 per million tokens for Opus 5.5).

Is Sonnet 5.5 good enough for coding?

Yes, for most well-scoped tasks such as single-ticket features, tests, and reviews. Anthropic describes it as the best combination of speed and intelligence for everyday coding. Move a task type to Opus 5.5 only if your own tests show Sonnet failing it.

Is Claude Fable 5.1 better than Opus 5.5 for coding?

Fable 5.1 is Anthropic's most capable model for all customers, built for demanding reasoning and long-horizon agentic work. It costs 2.5 times as much as Opus 5.5, and it can fall back to another model when its safety classifiers flag a request. Use it for the hardest multi-hour tasks, not as a default.

What is the cheapest Claude model for coding?

Claude Haiku 5.5, at $0.10 input and $0.50 output per million tokens for prompts up to 100,000 tokens (October 27, 2026). It is best for sub-agent work like triage and summarization rather than complex edits.

What is the best Claude plan for coding?

If you use Claude Code mainly through a subscription, compare the current plans and usage limits on claude.com/pricing. If you run agents through the API, there is no plan to choose: you pay per token, and the model, effort level, and cache hit rate decide the bill.

Bottom line

Default to Claude Opus 5.5 for serious coding agents, use Sonnet 5.5 for volume, give Haiku 5.5 the chores, and keep Fable 5.1 for the few tasks that justify 2.5 times the price. Pin full model IDs, tune effort before switching models, cache your system prompt and tools, and measure cost per finished task. To compare Claude with other providers, see the Flatkey model catalog and pricing. For Claude-specific gateway setups, read Claude vs GPT API routing.