Agent loop pricing

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

Raw conversation21,700tokens
Billed input135,600tokens
Multiplier6.2×
With 90% caching−69%cost

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

Sent on every single step. Usually cacheable.
One step is one model call. A tool call plus its response counts as one.
Include reasoning tokens. They are billed as output.
Search results, file reads, API responses. The quiet budget killer.
Failed tool calls, malformed output, guardrail rejections.
Cached input costs about 90% less. The biggest single lever you have.

Scale

Cost of one run

···
Per run
···
Per day
···
Per month
···
Per year

Where the money goes

Context re-sent System prompt Output Task input

Same workload, every model

ModelPer run Per monthvs. best

Cost accumulation by step

StepContext sentStep cost Running total
Step 1 is cheap. Step 40 is not. Context sent at step 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:

N × (system + user) + (output + tool_result) × N × (N−1) / 2

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

  1. 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.
  2. 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.
  3. 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?
Every step of the loop re-sends the entire prior context, because the model holds no state between calls. Total input across N steps is 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.
What is the fastest way to reduce agent costs?
Prompt caching, usually by a wide margin, because most of the bill is re-sent context and cache reads cost about 90% less. Reducing step count comes next, since step count is superlinear while price is linear. Trimming tool-result size is third, because each result is re-sent by every subsequent step.
How is this different from a normal LLM pricing calculator?
Standard calculators price a single API request: input tokens times rate, plus output tokens times rate. That is correct for a chatbot, and it understates agent costs by several times, because it ignores the context re-sent on every step of the loop.
Does this send my data anywhere?
No. Every calculation runs in your browser. There is no account, no request carrying your numbers and no analytics on what you type. Shareable links encode the configuration in the URL itself, so the link is the only thing that travels.
Where do the prices come from?
Each rate is taken from the provider's own public pricing page and carries a verification date. Prices were last checked in August 2026. Claude Sonnet 5's $2 / $10 rate is introductory and reverts to $3 / $15 on 1 September 2026. Confirm against the official page before you commit budget.