The short version: you cannot compare coding agents on dollars-per-million-tokens, because a coding agent doesn't send one prompt — it runs a long, input-heavy loop. A single SWE-bench-class task burns 1 to 3.5 million tokens including retries, and roughly three-quarters of them are reads. So the number that predicts your bill is dollars-per-task, and two levers — caching and a tokenizer gotcha — move it more than the model name does. Below is the real math, the verified prices, and which model to pick at each budget.

Why the sticker price lies#

Chat intuition says output is the expensive part. For a coding agent, that intuition is backwards. To close one bug an agent reads files, calls tools, reads the output, edits, re-runs the tests, and self-corrects — often a dozen turns. Published token-consumption studies of agentic coding put a single task at ~1M–3.5M tokens total, with read-type operations around 76% of them. Output — the actual code it writes — is a thin slice.

That means a model with a scary-looking output price can be cheaper to run than one with a low output price but a high input price, because you'll spend far more tokens reading than writing. Compare on the whole task, not the headline rate.

The real per-task math#

Here's an illustrative mid-range task — ~1.5M input + ~100K output, uncached — priced across the models a founder would actually point an agent at. Swap in your own token count once you've measured it; the ranking is what's stable.

At a glance below. The frontier tier (Opus 5, GPT-5.6 Sol) clusters near $10 a task; the strong-mid tier (Sonnet 5 on intro pricing, GPT-5.6 Terra, Gemini 3.1 Pro) near $4; and the open-weight floor runs from GLM-5.2 at ~$2.50 down to Qwen3-Coder-Next at ~$0.26. That's a 40x spread for the same task — before you touch the two levers that matter most.

Lever 1: caching cuts the bill 5–10x#

A coding agent re-sends the same context — system prompt, project files, tool definitions — on nearly every turn. Cache reads bill at ~10% of the base input price across the major vendors, and since input dominates the bill and the context repeats every turn, caching well cuts real cost 5–10x versus a naive implementation.

Anthropic's own worked example makes it concrete: a small Opus 5 session of 50K input + 15K output costs about $0.63 in tokens uncached, dropping to about $0.32 when 40K of that input is cache reads (Anthropic pricing). Structure prompts so the stable context is cacheable and new content appends at the end, and the discount compounds across a long session. This one change beats most model-switching decisions.

Lever 2: the tokenizer gotcha#

A trap hiding in plain sight: Claude Opus 4.7 and later — including Opus 5 — use a newer tokenizer that emits about 30% more tokens for the same text than earlier Claude models and many rivals (Anthropic). So Opus 5's real per-task cost runs above its sticker when you compare it against an older model or a competitor at the same nominal rate — the same file just costs ~30% more tokens to read. It doesn't make Opus 5 a bad pick; the tokenizer is part of why it reasons well. It does mean: compare on measured dollars-per-task, never on the headline $/1M.

What changed in the last two weeks#

This market reprices weekly, so treat any number as perishable:

The decision#

The math points to one pattern: run the cheapest model that passes your evals by default, and escalate only the hard tasks. For routine edits — boilerplate, refactors, test scaffolding, straightforward fixes — a strong open-weight coder like Qwen3-Coder-Next (~$0.26/task) or DeepSeek V4-Pro (~$0.74/task) does the work for cents, with no lock-in. Reserve a frontier model (Opus 5, GPT-5.6 Sol) for gnarly debugging and large multi-file changes where a wrong answer is expensive.

The prerequisite is evaluation. You can't route by difficulty if you can't tell which model passed, and you can't trust a leaderboard: SWE-bench Verified scores swing from the low 70s to the low 90s for the same models depending on the harness (Vals AI). So freeze 15–30 real tasks from your own codebase with known-good outcomes, run each candidate through the same agent scaffold, and record both pass rate and tokens-per-task. That gives you the two numbers that matter together — did it solve the task, and what did solving it cost — which is the only comparison a leaderboard can't do for you. If you're weighing this specifically across the coding-optimized frontier models, we go deeper in Kimi K3 vs Opus vs GPT-5.6 on coding-agent cost.