Which Claude AI model is best for solving coding questions?
Claude Opus 4.8 is Anthropic's own recommendation for complex agentic coding, at $5 per million input tokens and $25 output. Claude Sonnet 5 delivers frontier coding performance at $3/$15 (introductory $2/$10 through August 31, 2026) and is the better default for most work. Claude Fable 5 is the most capable overall at $10/$50.
Why — the first-principles explanation
Anthropic's docs give an unusually direct answer: start with Claude Opus 4.8 for complex agentic coding and enterprise work, and reach for Claude Fable 5 only when you need the highest available capability. Note that Opus 4.8 — not the more expensive Fable 5 — is the stated pick for coding specifically. More capable overall does not automatically mean better at your task.
The economics explain why "just use the best model" is bad advice. As of 2026-07: Haiku 4.5 is $1 in / $5 out per million tokens, Sonnet 5 is $3/$15 (with introductory $2/$10 running through August 31, 2026), Opus 4.8 is $5/$25, and Fable 5 is $10/$50. That's a 10x spread on output tokens between Haiku and Fable. Coding agents are output-heavy and iterate in loops, so that multiplier compounds fast. Picking Fable 5 to rename a variable is like chartering a jet to cross the street.
Two capability facts matter more than the benchmark leaderboard. First, context: Fable 5, Opus 4.8, and Sonnet 5 all carry a 1 million token window (~555,000 words) with 128k max output, while Haiku 4.5 has 200k. For dropping an entire repository into the prompt, the top three are equivalent — you don't pay up for context. Second, a tokenizer gotcha: Fable 5 uses the tokenizer introduced with Opus 4.7, so the same code produces roughly 30% more tokens than on older models. Fable 5's headline price is 2x Opus 4.8, but your effective bill runs higher than 2x on identical input.
One more lever most people miss. On Opus 4.8 the `effort` parameter defaults to `high` everywhere — API, Claude Code, and claude.ai. You can dial effort down for routine work and cut cost and latency without switching models at all. Model choice is not the only knob.
An example that makes it click
Think about hiring for a kitchen renovation. You don't call the master architect to unclog the sink — you call a plumber, and she's done in twenty minutes for a fraction of the price. You call the architect when you're moving load-bearing walls.
Haiku 4.5 is the plumber: $1 per million tokens, fast, perfect for "what does this error mean?" Sonnet 5 is a great general contractor and handles most real jobs. Opus 4.8 is the specialist you call for the load-bearing work — refactoring a system, debugging something that spans twelve files. Fable 5 is the world expert who bills $50 per million output tokens and reads 30% more meter than everyone else. Worth it for the impossible job. Absurd for the sink.
How to do it
- Default to Claude Sonnet 5 for everyday coding — frontier performance at $3/$15 per million tokens, and $2/$10 through August 31, 2026.
- Switch to Claude Opus 4.8 for complex agentic coding, multi-file refactors, and long-running tasks. This is Anthropic's documented recommendation for coding work.
- Use Claude Haiku 4.5 ($1/$5) for quick lookups, error-message explanations, and high-volume simple edits where latency matters more than depth.
- Reserve Claude Fable 5 ($10/$50) for problems the others genuinely fail at. Budget extra: its tokenizer produces roughly 30% more tokens for the same code.
- Tune the `effort` parameter instead of jumping models — it defaults to `high` on Opus 4.8 across the API, Claude Code, and claude.ai. Lowering it cuts cost and latency.
- For huge codebases, note that Fable 5, Opus 4.8, and Sonnet 5 all have the same 1M token context — you do not need to pay more to fit more code.
- If you're on claude.ai, remember model selection requires Pro or above ($17/month annual as of 2026-07). The free tier does not let you choose.
Key facts
- Anthropic's docs recommend starting with Claude Opus 4.8 for complex agentic coding and enterprise work, and Claude Fable 5 for the highest available capability (as of 2026-07).
- Claude Sonnet 5, released June 30, 2026, is described by Anthropic as delivering frontier performance across coding, agents, and professional work at scale.
- Pricing per million input/output tokens as of 2026-07: Haiku 4.5 $1/$5, Sonnet 5 $3/$15, Opus 4.8 $5/$25, Fable 5 $10/$50.
- Claude Sonnet 5 has introductory pricing of $2/$10 per MTok through August 31, 2026.
- Fable 5, Opus 4.8, and Sonnet 5 all have 1M token context windows and 128k max output; Haiku 4.5 has 200k context and 64k output.
- Claude Fable 5 uses the tokenizer introduced with Claude Opus 4.7 — the same text produces roughly 30% more tokens than on models before Opus 4.7.
Anthropic's assistant, known for long-document reasoning and careful, safe answers.
▶ The 60-second explainer (script)
Which Claude model is best for coding? Anthropic actually answers this in their own docs, and the answer surprises people. It's Claude Opus 4.8 — not the more expensive Fable 5. Opus 4.8 is their stated pick for complex agentic coding. Fable 5 is for maximum raw capability, which is not the same thing. But here's my real advice: default to Sonnet 5. It's frontier-level at coding, it costs three dollars per million input tokens versus five for Opus, and right now there's introductory pricing at two dollars running through August thirty-first, 2026. Move up to Opus 4.8 when you're doing multi-file refactors or long agent runs. Two things people miss. One: context is free. Fable 5, Opus 4.8, and Sonnet 5 all read one million tokens — about five hundred fifty-five thousand words. You don't pay more to fit your whole repo. Two: Fable 5 uses a newer tokenizer that turns the same code into about thirty percent more tokens. So its price isn't just double Opus — your actual bill runs higher than double. And before you upgrade models, try turning down the effort parameter. On Opus 4.8 it defaults to high everywhere. Dial it back for routine work and you save money without changing models at all.
What authoritative sources say
People also ask
Is Fable 5 better at coding than Opus 4.8?
Fable 5 is Anthropic's most capable widely released model, but their docs specifically name Opus 4.8 for complex agentic coding. For most coding work Opus 4.8 is the recommended starting point at half the price.
Which Claude model does Claude Code use?
Claude Code supports the current models, and Opus 4.8 defaults to `effort: high` there. Model availability depends on your plan — Claude Code requires Pro or above.
Can I use the best coding model for free?
No. Model selection on claude.ai requires Pro ($17/month annual as of 2026-07). The free tier does not include model choice or Claude Code.
Do I need a bigger model for a large codebase?
No. Fable 5, Opus 4.8, and Sonnet 5 all have identical 1M token context windows. Size of codebase is not a reason to move up from Sonnet 5.
Why is my Fable 5 bill higher than 2x Opus 4.8?
Fable 5 uses the tokenizer introduced with Opus 4.7, which turns the same text into roughly 30% more tokens. That compounds on top of the 2x list price.