What does one agent run actually cost?
Most calculators price a single API call. An agent makes dozens of them, and every step re-sends everything that came before it. Input tokens grow with the square of the step count. This models that.
17 models · No signup · Nothing leaves your browser
A 12-step agent. 2,000-token system prompt, 500-token task, 400 output and 1,200 tool-result tokens per step, zero retries. The calculator below defaults to a 10% retry rate, which reports 6.9×, because retries re-send context too.
Model your workload
Set the shape of one agent run. Everything recalculates as you drag, and the URL updates so you can share the exact configuration.
Workload
Scale
Cost of one run
…Where the money goes
Same workload, every model
| Model | Per run | Per month | vs. best |
|---|
Cost accumulation by step
| Step | Context sent | Step cost | Running total |
|---|
i equals system + input + (i−1) × (output + tool result), which makes total input tokens grow as O(N²) rather than O(N). Capping steps or trimming tool output beats switching models more often than teams expect.Why agent costs surprise people
Language models are stateless. They remember nothing between calls, so an agent has to re-send its entire history on every step. Step 1 sends a little. Step 2 re-sends step 1 plus whatever is new. Step 10 pays for steps 1 through 9 all over again.
Total input tokens across N steps come out as:
That second term is quadratic. Double the steps and you roughly quadruple the input cost. It is the most consistent reason real invoices beat estimates.
A worked example
A 12-step agent with a 2,000-token system prompt, 500-token task, 400 output tokens and 1,200 tool-result tokens per step has a raw conversation length of 21,700 tokens, and bills 135,600 input tokens. That is a 6.2× multiplier which shows up on the invoice and in nobody's estimate.
The 6.2× figure is the context effect on its own, at a 0% retry rate. The calculator defaults to a more realistic 10% retry rate, which is why it reports 6.9×. Retries re-send context too. Set retries to zero to isolate the pure loop effect.
The three levers, in order
- Prompt cachingMost of the bill is context re-sent verbatim, and cache reads cost roughly 90% less. In the example above, a 90% hit rate takes the run from $0.351 to $0.110 on Claude Sonnet 5. Same model, same agent.
- Step countCutting steps beats switching to a cheaper model in most configurations, because step count is superlinear while price is linear. Going from 20 steps to 10 saves more than moving from a frontier model to a small one.
- Tool-result sizeUnderrated, because every tool result is re-sent by every step that follows it. Truncating a 5,000-token search result to 1,000 compounds across the whole run.
Assumptions and limits
Retries are modelled as a flat multiplier on total cost. Real retries occur at a specific context depth, so failures late in a run are under-counted. Cache hit rate is a single figure rather than per-prefix. Providers use different tokenizers, so cross-vendor token counts are approximate. OpenAI's GPT-5.6 charges 1.25× uncached input for cache writes, which is not modelled here, only reads. Treat the output as a planning estimate, not a billing forecast.
Questions
Why does an AI agent cost more than the token math suggests?
N × (system + user) + (output + tool result) × N × (N−1) / 2. The second term is quadratic, so a 12-step agent with a 2,000-token system prompt and 1,200-token tool results bills about 135,600 input tokens against a raw conversation length of 21,700.