All guides
Planning

How Much Does an AI Agent Cost per Task? Worked Examples With Real Prices

Why agent tasks cost 10 to 40 times a single chat call, with step-by-step token math for a coding fix and a research task, priced on five models with and without caching.

A 10-step coding-agent task costs about $0.19 on Claude Sonnet 5.5 and about $0.39 on Claude Opus 5.5 at list prices, before caching. That is roughly 19 times what a single request with the same starting prompt would cost, and the multiple keeps growing with each added step. Prompt caching can cut the same task to about a third. This guide builds those numbers up step by step so you can swap in your own.

Prices are per 1 million tokens, as of November 25, 2026, from the data on this site. Every token count for the agents below is an assumption, labeled as such. Real agents vary a lot, so treat the results as a planning model and replace the inputs with traces from your own runs. The arithmetic matches the site's agent cost calculator, which uses the same model.

Why an agent costs more than a chat

Chat APIs are stateless. Each call carries the whole conversation so far, and you pay for all of it as input every time. An agent is a loop of calls: the model decides on an action, a tool runs, the result is appended, and the model is called again with everything. Three things drive the bill.

The fixed context is resent every step. The system prompt and the tool definitions go out with every call. In a 10-step task they are billed 10 times.

History accumulates. Each step adds the model's own message plus the tool's result. Step 1 sends the fixed context. Step 2 sends that plus step 1's additions. Step 10 sends the fixed context plus nine steps of history. Total input tokens across N steps are N × fixed + growth × N(N-1)/2, so they grow with the square of the step count, not linearly.

Tool results are the bulk of the growth. A file read or a search result can run to hundreds or thousands of tokens. The model generates only a small part of the context it reads. Output stays small and input dominates.

On top of that, some steps fail or get repeated. The site's model handles this as a flat retry overhead on the total, which is the simplest honest way to represent it.

Worked example 1: a 10-step coding fix

Assumptions (these match the site's coding-agent preset except for the step count, which we set to 10):

  • Fixed context: 3,000 tokens (system prompt plus tool definitions)
  • Context added per step: 850 tokens (the model's message plus the tool result)
  • Output per step: 280 tokens
  • Retry overhead: 18%

The input sent on each step:

StepInput tokens sent
13,000
23,850
34,700
45,550
56,400
67,250
78,100
88,950
99,800
1010,650

Totals: 68,250 input tokens and 2,800 output tokens, a ratio of about 24 to 1. Of the input, 30,000 tokens (44%) are the fixed context sent ten times and 38,250 (56%) are history. The final step sends 3.6 times as many tokens as the first.

A single non-agent call with the same 3,000-token prompt and 280 output tokens costs $0.0104 on Sonnet 5.5 including the same 18% overhead. The 10-step task costs $0.194, so the agent is about 18.7 times a single call.

Worked example 2: a 5-step research task

Assumptions:

  • Fixed context: 1,800 tokens
  • Context added per step: 900 tokens (search results and fetched page excerpts are larger than a typical code edit)
  • Output per step: 220 tokens
  • Retry overhead: 12%

Input per step is 1,800, 2,700, 3,600, 4,500 and 5,400 tokens. Total: 18,000 input tokens and 1,100 output tokens. Even though the task is half as long and the context starts smaller, the quadratic shape is the same, just flatter.

Pricing both tasks on five models

We picked five models across the price range. The scores are ECI values from /benchmarks, shown so you can see what the price buys. They are a general capability index, not a measure of agent skill, so test on your own tasks.

ModelInput / output per 1MECI
DeepSeek V4.1 Flash$0.051 / $0.203157.0
GPT-6.1 Terra$1 / $5167.7
Claude Sonnet 5.5$2 / $10166.6
Claude Opus 5.5$4 / $20168.7
GPT-6.2 Astra$8 / $40172.8

Cost per 1,000 tasks with no caching:

Model10-step coding fix5-step research task
DeepSeek V4.1 Flash$4.78$1.28
GPT-6.1 Terra$97.06$26.32
Claude Sonnet 5.5$194.11$52.64
Claude Opus 5.5$388.22$105.28
GPT-6.2 Astra$776.44$210.56

Output is a minority of the bill: 14% on DeepSeek V4.1 Flash and 17% on the other four for the coding task, 20% and 23% for the research task. That is the opposite of a chat that writes long answers, and it is why cache pricing matters so much here.

Notice the spread. The cheapest and most expensive model are about 160 times apart on the same task. Terra has a higher ECI than Sonnet 5.5 at half the price, which is the kind of gap worth testing on your own tasks before defaulting to a familiar name.

What caching does to the numbers

An agent loop is close to the ideal case for prompt caching. Each call starts with exactly the same prefix as the previous one: the fixed context, then all earlier history. Only the newest step's additions are new.

We model two setups. Both assume step 1 pays the full input price, later steps hit the cache every time, and cached tokens are billed at each model's listed cache-read rate.

  • Fixed prefix only: the system prompt and tool definitions are cached, but the growing history is billed at the full input price (this is what you get if you cache only a manually marked static block).
  • Full prefix: everything except the 850 newly added tokens is a cache read on every step after the first.

Cost per 1,000 tasks, 10-step coding fix:

ModelNo cacheFixed prefix cachedFull prefix cachedSaving
DeepSeek V4.1 Flash$4.78$3.18$1.3871%
GPT-6.1 Terra$97.06$66.79$32.4967%
Claude Sonnet 5.5$194.11$133.58$64.9767%
Claude Opus 5.5$388.22$267.15$129.9467%
GPT-6.2 Astra$776.44$534.30$259.8867%

Cost per 1,000 tasks, 5-step research task:

ModelNo cacheFixed prefix cachedFull prefix cachedSaving
DeepSeek V4.1 Flash$1.28$0.88$0.5755%
GPT-6.1 Terra$26.32$18.66$12.9151%
Claude Sonnet 5.5$52.64$37.32$25.8351%
Claude Opus 5.5$105.28$74.64$51.6551%
GPT-6.2 Astra$210.56$149.27$103.3151%

Two things stand out. First, caching the history matters more than caching only the fixed prefix: the longer the task, the more of the input is history. Second, savings are smaller on the shorter task because output and the one uncached first step make up a bigger share. A longer loop gets more from caching, not less.

These are best cases. They assume a 100% hit rate, no cache-write premium and each step arriving before the cached prefix expires. Providers differ on write fees, minimum cacheable lengths and expiry, so confirm the rules for your provider, and use /cache-savings to try other hit rates. A realistic result is likely to land between the "fixed prefix" and "full prefix" columns.

How the bill scales with steps

Step count is the lever that matters most because of the square term. Same coding assumptions as above, priced on Sonnet 5.5 with no caching:

StepsInput tokensOutput tokensCost per task
523,5001,400$0.072
1068,2502,800$0.194
20221,5005,600$0.589
30459,7508,400$1.184

Going from 10 to 20 steps doubles the work but costs 3.0 times as much. At 30 steps, history is 80% of the input. An agent that wanders is far more expensive than one that finishes in the expected number of steps, and a failed 30-step run costs six times as much as a successful 10-step one at these assumptions ($1.18 against $0.19).

At volume, a coding agent on Sonnet 5.5 with 100,000 tasks a month costs about $19,411 uncached and about $6,497 with full-prefix caching.

How to cut it

  1. Cap the steps. A hard limit and an early-exit rule are worth more than any model swap, because cost is quadratic in length.
  2. Make the loop prefix-stable. Put the system prompt and tools first, never reorder or edit earlier messages, and append only. A single edit near the top invalidates the cache for everything after it.
  3. Trim tool results before they enter history. Return the 40 relevant lines of a file rather than the whole file, or truncate long search results. Each token you leave out is saved again on every later step.
  4. Prune or summarize history on long tasks. Summarizing older steps breaks the cached prefix once, then shrinks every later call. Compare against the cached cost, not the uncached cost, to see whether it pays.
  5. Trim tool definitions. Only register tools the agent needs for this task. Every definition rides along on every step.
  6. Route by step. Planning and the hard edit may need a stronger model, while reading files and running tests rarely do. Compare prices on /compare and /price-performance.
  7. Measure real traces. Log input and output tokens per step for 50 real runs, take the median and the 90th percentile of step count, and put those into the agent cost calculator. Check /rate-limits too: long agent loops burn tokens per minute quickly.

For cost levers beyond agents, see how to cut LLM API costs and the cheapest LLM for coding. To count tokens in your own prompts and tool schemas, use the token counter. The inputs behind our numbers are described in /methodology.