AI Agent Cost per Task
Why a 62% Cheaper Model Can Make Your AI Agent Cost 26% More per Task
On paper, moving an 8-step agent from Claude Sonnet 5.5 to GPT-5.4 mini cuts the cost of a run by 62%. If the cheaper model needs 14 steps and passes the final check 70% of the time, each finished task costs 26% more, and a $2,086 monthly budget turns into a $6,279 bill. Here is every price, assumption and formula, plus the one setting that decides which model wins.
A lower token price does not mean a cheaper agent. Priced with list rates checked for the 2026-11-03 dataset snapshot, an 8-step agent run costs $0.2464 on Claude Sonnet 5.5 and $0.0948 on GPT-5.4 mini. But if mini needs 14 steps for the same task, its run costs $0.2415, because every step resends the whole conversation. Add a 70% pass rate against Sonnet's 90%, one retry each, and mini costs $0.3450 per finished task against Sonnet's $0.2738. With prompt caching working, the gap mostly closes: $0.1018 against $0.1056.
| Model | Input $/1M | Cached input $/1M | Output $/1M | Source | Last verified How we verify |
|---|---|---|---|---|---|
| Claude Sonnet 5.5 | $2.00 | $0.10 | $10.00 | Official source | Oct 9, 2026 |
| GPT-5.4 mini | $0.75 | $0.075 | $4.50 | Official source | Oct 25, 2026 |
Prices from official provider pages, verified on the date shown.
10 min read - Published Nov 3, 2026 - Updated Nov 3, 2026
A $2,086 budget and a $6,279 bill
GPT-5.4 mini lists input at $0.75 per million tokens. Claude Sonnet 5.5 lists it at $2. Run the same 8-step agent task on both and mini costs $0.0948 a run against Sonnet's $0.2464, 62% less. At 20,000 tasks a month that is $2,086 instead of $5,421. That is the spreadsheet you make before you switch.
Now change two numbers. Say mini needs 14 steps where Sonnet needs 8, and passes the final check on 70% of runs where Sonnet passes 90%. Same prices, same task. Mini now costs $6,279 a month, leaves 1,800 tasks unfinished, and each finished task costs 26% more than on Sonnet.
I built this from the prices in our AI API pricing dataset. The token shape, step counts and pass rates are assumptions, not measurements from a real agent, and I say so wherever they matter. The point is the mechanism, and the exact point where a cheaper model stops being cheaper. You can plug in your own numbers at the end.
The prices behind every number
These are official list prices from the dataset snapshot generated on 2026-11-03, per million tokens, standard processing, prompts under the long-context threshold.
| Model | Input | Cached input | Cache write | Output | Last verified |
|---|---|---|---|---|---|
| Claude Sonnet 5.5 | $2.00 | $0.10 | $2.50 (5-minute cache) | $10.00 | 2026-10-09 |
| GPT-5.4 mini | $0.75 | $0.075 | No write fee | $4.50 | 2026-10-25 |
| Mini vs Sonnet | 62.5% cheaper | 25% cheaper | 70% cheaper | 55% cheaper |
Look at the cached input column. The discount you see on the pricing page is 62.5%. On cached tokens it is 25%. Keep that in mind; it matters later. Current rates for both models are on the Claude Sonnet 5.5 pricing page and the GPT-5.4 mini pricing page.
The agent we priced
- First request: 5,000 tokens of system prompt, tool definitions and the task itself.
- Each step: the model writes 400 output tokens (a tool call), the tool returns 2,000 tokens, and both get appended to the conversation.
- Every step resends the whole conversation. That is how chat-style agent loops work unless you summarize or trim history.
- At the end a check runs (tests, a schema, a grader). If it fails, the task runs once more from scratch. After two failed runs the task is unfinished.
- Claude Sonnet 5.5: 8 steps per run, passes 90% of runs (assumption).
- GPT-5.4 mini: 14 steps per run, passes 70% of runs (assumption).
- No extended thinking or reasoning tokens on either model.
The resend is the part people underestimate. Step 1 sends 5,000 tokens. Step 8 sends 21,800. Step 14 sends 36,200. Add them up and an 8-step run sends 107,200 input tokens, while a 14-step run sends 288,400. That is 75% more steps and 169% more input tokens.
| Step | Input tokens sent on this step | Running total |
|---|---|---|
| 1 | 5,000 | 5,000 |
| 4 | 12,200 | 34,400 |
| 8 | 21,800 | 107,200 |
| 11 | 29,000 | 187,000 |
| 14 | 36,200 | 288,400 |
The extra steps eat the whole discount
First, with no prompt caching, which is what you get when caching is off, when your prompt changes at the top on every call (a timestamp in the system prompt is the classic one), or when the cache has expired between steps.
Six extra steps take mini from $0.0948 to $0.2415 a run. That is 98% of what Sonnet costs, before a single run fails. The 62% saving is gone, and nothing on the pricing page warned you.
Then the failed runs land
A failed run is paid for in full and finishes nothing. With one retry, Sonnet finishes 99% of tasks and spends 1.1 runs per task on average. Mini finishes 91% and spends 1.3 runs per task. The third route is the one people usually build: mini first, and anything mini can't finish goes to Sonnet from scratch.
| Route (no caching) | Cost per incoming task | Tasks finished | Cost per finished task | 20,000 tasks a month |
|---|---|---|---|---|
| Sonnet 5.5 only | $0.2710 | 99.00% | $0.2738 | $5,421 |
| GPT-5.4 mini only | $0.3140 | 91.00% | $0.3450 | $6,279 |
| Mini, Sonnet as fallback | $0.3383 | 99.91% | $0.3386 | $6,767 |
Routing mini's failures to Sonnet finishes almost every task, but it costs $1,346 a month more than sending everything to Sonnet in the first place. You pay for mini's attempts and then pay Sonnet's full price for the 9% it couldn't do.
If your fallback fires more often than you think, this gets worse fast. We worked out the fallback rate at which you should just switch your primary model in a separate piece.
Turn prompt caching on and mini wins again, barely
Now the best case: every step reads the previous request from cache and pays full price only on the 2,400 new tokens. OpenAI caches automatically with no write fee. Anthropic charges $2.50 per million to write new tokens into its 5-minute cache and $0.10 to read them back.
| Route (caching works) | Cost per run | Cost per finished task | 20,000 tasks a month |
|---|---|---|---|
| Sonnet 5.5 only, 8 steps | $0.0950 | $0.1056 | $2,091 |
| GPT-5.4 mini only, 14 steps | $0.0713 | $0.1018 | $1,853 |
| Mini, Sonnet as fallback | $0.1021 | $2,041 |
Everything gets cheaper, and the order flips. With caching, resending the old conversation costs very little, so a run costs roughly in proportion to its steps instead of growing with the square of them. Mini's six extra steps now cost it about 1.9 times a short run, not 2.5 times.
But look at the size of the win. Mini only is 3.6% cheaper per finished task, $238 a month on 20,000 tasks, and it leaves 1,800 tasks unfinished. The safer mini-plus-fallback route saves $50 a month. If your cache hit rate is 80% instead of 100%, or the cache expires while a tool runs, that margin is gone.
So the honest answer to "is the cheaper model cheaper?" is: check your cache hit rate first. It moves the result more than the model choice does. The prompt caching savings calculator shows what your hit rate is worth on a given model.
Break-even: how good does the cheap model have to be?
This is the table worth saving. Keep Sonnet at 8 steps and a 90% pass rate. For each step count mini might need, here is the lowest pass rate at which mini alone still costs no more per finished task than Sonnet alone.
| Mini steps per run | Break-even pass rate, no caching | Break-even pass rate, caching works |
|---|---|---|
| 8 (same as Sonnet) | 34.6% | 35.2% |
| 10 | 49.9% | 45.3% |
| 12 | 67.7% | 56.0% |
| 14 | 88.2% | 67.5% |
| 16 | Never, even at 100% | 79.6% |
Two things jump out. If mini finishes in the same number of steps, it can fail almost two runs in three and still be cheaper. The pass rate is not the main risk. The step count is. And without caching the bar rises fast: at 16 steps no pass rate saves it, because a single run already costs more than Sonnet's.
The formula
context(k) = 5,000 + (k - 1) × (400 + 2,000) # input tokens on step k
run, no cache = Σ_k [context(k) × input + 400 × output] / 1e6
run, cached = Σ_k [context(k-1) × cached + new(k) × write + 400 × output] / 1e6
# new(1) = 5,000, new(k) = 2,400; write = input price when there is no write fee
cost per task = run × (1 + (1 - pass)) # one retry
finished share = 1 - (1 - pass)^2
cost per finished = cost per task / finished share
with fallback: cost = cheap.cost + (1 - cheap.finished) × strong.cost
finished = cheap.finished + (1 - cheap.finished) × strong.finishedEvery number in this post comes from a short script that reads both prices straight from the dataset and runs exactly these lines, so the post can be re-checked whenever either price changes.
Where this math can be wrong
- The step counts and pass rates are made up to show the mechanism. Your agent may see no extra steps at all on a cheaper model, or twice as many.
- Cheap models do not always lose. In our own DeepSeek benchmark, the cheaper Flash model matched V4 Pro's accuracy on 720 graded tasks and cost 4.9 times less per correct answer. Those were single-call tasks, with no agent loop.
- Caching is modeled as all or nothing. Real hit rates sit in between, and OpenAI only caches prompts of 1,024 tokens or more.
- No reasoning tokens. If either model thinks before each tool call, its output cost per step goes up, often a lot.
- Retries here rerun the whole task. Retrying only a failed step is cheaper, and many frameworks do some of each.
- Prices change. Sonnet 5.5 was last verified on 2026-10-09 and GPT-5.4 mini on 2026-10-25.
The DeepSeek result is in DeepSeek V4 Pro vs Flash: cost per correct answer. It is the reason I would not tell anyone to avoid cheap models. Measure first, then decide.
Three numbers to pull from your logs before you switch
- Steps per finished task on each model, from a few hundred real tasks, not five demos.
- Pass rate on your final check, with the same check for both models.
- Cache hit rate: cached input tokens divided by all input tokens, straight from the usage fields your provider returns.
If you have agent traces, the agent trace cost replay re-prices them at current list prices and gives cost per successful task without uploading your prompts. If you only have estimates, put them in the LLM retry and fallback cost calculator. And if you do switch, save the workload in the model switch calculator so you get flagged when either model's price changes.
Ten minutes with those three numbers tells you which row of the break-even table you are in. Skipping it is how a 62% saving turns into a bill three times the budget.
FAQ
Why can a cheaper LLM make an AI agent more expensive?
Because an agent resends its whole conversation on every step. If the cheaper model needs more steps to finish, input tokens grow much faster than the step count: in this example 75% more steps (14 instead of 8) meant 169% more input tokens. Failed runs that have to be redone add more on top. A model that is 62% cheaper per run can end up 26% more expensive per finished task.
How do I calculate AI agent cost per task?
Add up the input and output tokens of every step in a run, price them at your model's rates (cached input at the cached rate), and multiply by the expected number of runs per task including retries and fallbacks. Then divide total spend by the number of tasks that pass your final check. Failed runs stay in the cost and leave the finished count.
Does prompt caching make cheap models cheaper for agents?
It helps every model, but it changes which one wins. Without caching, the cost of a run grows roughly with the square of its step count, so a model that takes more steps is punished hard. With caching, the growing history is billed at the cached rate and cost grows roughly in line with steps. In this example caching moved GPT-5.4 mini from 26% more expensive per finished task to 3.6% cheaper.
How good does a cheaper model need to be before I switch my agent?
It depends on how many extra steps it takes. Against Claude Sonnet 5.5 at 8 steps and a 90% pass rate, GPT-5.4 mini at 14 steps needs to pass 88.2% of runs without caching, or 67.5% with caching, to cost the same per finished task. At 16 steps and no caching it never breaks even, even at a 100% pass rate.
Is a cheap model with an expensive fallback the safest option?
It protects the finish rate, not the bill. In this example routing mini's failures to Sonnet raised the finish rate from 91% to 99.91%, but without caching it cost $0.3383 per incoming task, $0.0673 more than sending everything to Sonnet. With caching it saved about $50 a month on 20,000 tasks.
Run your own agent's numbers before you switch.
Enter your token counts, retries, fallback share and how many tasks end unresolved. The calculator prices the full route with current list prices and returns cost per finished task, not cost per call.