- Published on
Cost per Completed Task: How I Compare AI Models on Price
- Authors

- Name
- Mehdi Akiki
Article · Measurement
The price list for Claude says this, per million tokens: Haiku 5.5 costs USD 0.10 for input and USD 0.50 for output, Sonnet 5.5 costs USD 2 and USD 10, and Opus 5.5 costs USD 4 and USD 20. These are list prices from November 2026. So Opus is 40 times more expensive than Haiku, and Sonnet 20 times. Simple, right?
Then I looked at the bills from my own runs. On the same 40 Rust fixes, an Opus call cost on average about 35 times a Haiku call, and a Sonnet call about 16 times. When I counted only the fixes I accepted, the numbers moved again. And on the cases where at least one model failed, Sonnet, the model in the middle, was more expensive per accepted fix than Opus.
This article uses the runs from my test of four model settings on 40 failing Rust programs. That article asks which model fixes the errors. This one asks how to put a price on a finished task, and why price per token gives the wrong picture.
What one call really contained
My prompt for a case was small: the failing file, the compiler output and one sentence. Most files have fewer than 20 lines. But every call reported about 10,000 input tokens.
Where did they come from? I ran the same setup once with the prompt "Reply with the word OK." That call reported 9,722 input tokens. So about 9,700 tokens come with every call, whatever I ask. This is what Claude Code sends with every request: the definitions of the tools it still offers, its own system text, a list of skills and a description of the environment. My one-sentence system prompt did not remove them. Their size depends on the flags. I blocked only some tools, so 17 tools and the skill list stayed in every call. In my prompt caching test, with all tools turned off, only about 620 tokens were written per call.
These tokens are not all paid at the full price. Claude Code marks them for prompt caching. A cache write costs more than normal input, and a cache read costs much less. The pricing table gives, for Opus 5.5, USD 8 per million tokens for a write to the one-hour cache and USD 0.20 for a read. For Haiku 5.5 it is USD 0.20 and USD 0.01.
A typical first attempt in my runs looked like this:
- 6,406 tokens read from the cache. This part never changed between cases.
- about 3,600 tokens written to the cache: my prompt, plus about 3,300 tokens that Claude Code places after it.
- 2 tokens of normal input.
- a few hundred output tokens.
The order matters. Claude Code puts the environment and the skill list after the user message. My prompt is different for every case, so everything after it is new each time and is written to the cache again, on every call.
I checked the arithmetic. With the list prices, the token counts give exactly the total_cost_usd that Claude Code reported, for all 263 calls of this experiment, retries and test calls included. So I can split each bill:
| Setting | Average cost of a first attempt | Share that is fixed overhead |
|---|---|---|
| Haiku, medium | USD 0.00108 | 67 % |
| Sonnet, medium | USD 0.01774 | 78 % |
| Opus, medium | USD 0.03781 | 74 % |
| Opus, low | USD 0.03698 | 75 % |
"Fixed overhead" here means the 6,406 cached tokens plus the about 3,300 tokens (my estimate) that Claude Code writes after my prompt. So most of every bill paid for the same context again and again, not for the fix.
This is the first reason price per token misleads. The tokens are not only your tokens. On a small task, the fixed part decides the price.
The second reason is output. Haiku wrote on average 515 output tokens per fix, and 310 of them were thinking. Sonnet wrote 193, Opus at medium 317 and Opus at low 245. The cheap model did more work per task, so it closed a small part of the gap by itself. Also, cache reads on Opus and Sonnet cost 0.05 times their input price, on Haiku 0.1 times. So the cached part costs only 20 times more on Opus.
There is a third, smaller one. Calls are not always one request. In two of my 160 first attempts, Opus called a tool it did not need, a tool called ReportFindings once and a skill once. Each detour made extra requests, and those two calls cost USD 0.056 and USD 0.067, against about USD 0.035 to 0.037 for a normal Opus call.
The formula
Cost per completed task is the money for all attempts, divided by the tasks that are really done:
cost per completed task =
(first attempts + failed attempts + retries + escalations)
/ tasks that pass your acceptance rule
Every attempt counts, also the ones that failed. Every call carries its fixed overhead. And "done" must mean done. In my data there are two ways to say done:
- the fix compiles, and the program exits 0 (an automatic check)
- the fix passes the check, and I accept it after reading it
The two give different numbers:
| Setting | Cost per task that passed the check | Cost per accepted fix |
|---|---|---|
| Haiku, medium | USD 0.00108 | USD 0.00127 |
| Sonnet, medium | USD 0.01774 | USD 0.02218 |
| Opus, medium | USD 0.03781 | USD 0.04087 |
| Opus, low | USD 0.03793 | USD 0.03998 |
With the weak check, almost every task looks finished, and the cost per task is just the cost per call. With the strict rule, the wrong fixes become failed attempts that you paid for and got nothing from.
Retries were cheap
What happens when a fix is rejected and you ask again? I sent every case a second time to Haiku and Sonnet, with the same prompt, a few minutes after the first time.
| Setting | First attempt, average | Second attempt, average |
|---|---|---|
| Haiku, medium | USD 0.00108 | USD 0.00037 |
| Sonnet, medium | USD 0.01774 | USD 0.00308 |
Why is the second attempt so much cheaper? The whole prompt was already in the cache from the first attempt. Every second call read about 10,000 tokens from the cache and wrote nothing. For Sonnet, a retry cost about a sixth of the first attempt.
This only works inside the cache lifetime. Claude Code used the one-hour cache in my runs. A retry the next morning pays the full write again. It also only works because my retry sent the same prompt again. A retry that adds the reason for the rejection changes the prompt, so it pays the write for everything after the change again, like a first attempt.
Retries did not always help
Cheap is not the same as useful. A second sample can repeat the same mistake.
In RFA-135, a program forgets a mutex guard. Haiku "fixed" it by changing the check from is_ok() to is_err(), so the program now expects a stuck mutex. I asked three times. I got the same flip three times. In RFA-224, Haiku and Sonnet changed the expected value from abX to the zero-filled bytes in all six of their answers. Other cases did improve: two of Haiku's wrong fixes were right on the second try, and so was one of Sonnet's.
When I let each model try up to three times and stopped at the first accepted fix, Haiku reached 36 accepted tasks out of 40 for USD 0.04731 in total, USD 0.00131 per accepted task. Sonnet also reached 36, for USD 0.7548, which is USD 0.02097 per accepted task. The retries were cheap enough that the cost per accepted task hardly moved. But four tasks stayed unfinished for both.
A case where the cheap model is much cheaper
RFA-186 is a reader that calls fill_buf() twice without consume() and gets the same bytes again. All four settings added reader.consume(first.len()); on the first try, which is the fix in my repaired file. The costs:
| Setting | Cost of the accepted fix |
|---|---|
| Haiku, medium | USD 0.00109 |
| Sonnet, medium | USD 0.01812 |
| Opus, medium | USD 0.03870 |
| Opus, low | USD 0.03862 |
Same fix, about 35 times cheaper with Haiku. On the 29 cases where every setting gave an accepted fix on the first try, this is the whole story. Paying more bought nothing there.
A case where it is not
Now RFA-135 again. Say the plan is "Haiku first, try again if the reviewer rejects the fix, and send it to Opus after three rejections". Haiku's three attempts cost USD 0.00183 together, and all three were wrong. Opus at medium then fixed it for USD 0.03651. The total is USD 0.03834, which is more than Opus alone, and it needed three rounds of review before the right fix arrived. Opus at low effort fixed it on the first try for USD 0.03373.
So on this task, the cheap-first path was the most expensive path, and it needed the most calls.
The hard cases alone
Averages hide where the money goes. I called a case hard if at least one of the four settings did not produce an accepted fix on the first attempt. That gave 11 hard cases and 29 easy ones.
| Setting | Accepted, easy cases | Accepted, hard cases | Cost per accepted fix, hard cases |
|---|---|---|---|
| Haiku, medium | 29 of 29 | 5 of 11 | USD 0.00254 |
| Sonnet, medium | 29 of 29 | 3 of 11 | USD 0.06404 |
| Opus, medium | 29 of 29 | 8 of 11 | USD 0.05258 |
| Opus, low | 29 of 29 | 8 of 11 | USD 0.04970 |
By this definition, every setting got all 29 easy cases, so there the cheapest one wins. The hard set is chosen from the same single runs, so treat its numbers as a picture of these 11 cases, not as a rate. On these 11, the order changes. Sonnet paid half the Opus price per token and accepted only 3 of 11, so each accepted fix cost more than with Opus at low effort. Haiku stayed the cheapest even here, because it is so cheap per call. But it finished fewer than half of the hard tasks, and the API bill does not show what the unfinished ones cost you.
Limits of these numbers
One first attempt per case and setting, 40 cases. The runs were on my laptop on November 14 and 15, 2026, with Claude Code 2.1.325 and its default settings, except a one-sentence system prompt. Costs are Claude Code's reported cost at list prices, and the averages for Haiku, Sonnet and Opus at low effort each include one call with a cold cache. The tasks are small, so the fixed overhead is large; with long tasks, output and task tokens would matter more. The acceptance labels are my reading of each fix against the repaired file. And the bill does not include my reading time, which I did not measure.
How to compute it for your own feature
- Run a sample of real tasks, a few dozen at least, through each candidate. Use the same harness you will use in production, because the harness adds its own tokens.
- Keep the cost of every call, failed ones too. Claude Code gives
total_cost_usdandusagein its JSON output. - Write the acceptance rule before you look at results. Then apply it to every answer, not only to the ones that look wrong.
- Price the retry and the escalation path from real runs, with the cache state you will really have.
- Divide by accepted tasks, and look at the hard cases on their own. That is where a cheap model can stop being cheap.