AI agent token cost calculator
One agent task rarely makes one model call. When a task fans out into many tool calls, every call's payload and every earlier result can be re-sent as input, so the bill grows with the fan-out, not with the work. This calculator estimates that bill from your workload's shape — call count, payload sizes, replay, retries, workers, runs — and prices the same scenario two ways: raw tool calls versus one aggregated script.
The results also show what Agent Swarm saves. Its ROI section prices three levers, Code Mode, two-model PR review and dreaming, and each default comes from a number we measured in one of our posts.
How to use the calculator
- Tool calls per task and runs per day start filled. Fill tool result tokens per call, context replay, payload size per call, tool-call output per call, final answer tokens and retry rate to get an estimate, which updates live.
- Open Advanced inputs for model rates, payload, retries, workers, caching and batching. Rate defaults carry a retrieval date and a vendor link.
- Set the ROI fields under the results. PRs per month, your cost per PR review and instruction tokens per call start blank.
- Open Raw tool calls vs. aggregated script to price the same workload both ways.
Calculator
needs input: Tool result tokens per call, Context replay, Payload size per call, Tool-call output per call, Final answer tokens, Retry rate
- Estimate per month
- needs input
- Monthly low-high range
- needs input
- Estimate per run (lower bound)
- needs input
- Input tokens per run
- needs input
- Output tokens per run
- needs input
- Tool-call overhead per run
- needs input
- Orchestration / worker estimate
- needs input
What the swarm saves
Each lever reads a default we measured in one of our posts, so edit any field to match your setup. The order is dreaming, then Code Mode, then PR review, so no token counts twice.
% of the workload cost above
Default measured: per-run cost roughly halved, one daily triage job (Code Mode token savings)
reviews a month
$ per review today
$ per review with two-model triage
Default measured: $0.26 for 14 PRs, 2026-10-21 (Two small models triage every PR)
agent instructions sent with every call
% of instruction tokens removed
Default measured: instructions 52% shorter on average, 28 nights (How we got to 60% deterministic dreaming)
- Saving per month
- needs input
- Saving per year
- needs input
- Monthly spend: today → with the swarm
- needs input
- Share of spend saved
- needs input
These are our numbers, not yours. The 50% covers one daily triage job, $0.02 per PR came from 14 PRs, and 52% covers our agents' instructions; dreaming's own nightly run cost is not subtracted.
needs input: Tool result tokens per call, Context replay, Payload size per call, Tool-call output per call, Final answer tokens, Retry rate, Script summary size
- Calls per worker
- needs input
- Input tokens
- needs input
- Output tokens
- needs input
- Tool-call overhead
- needs input
- Calls per worker
- needs input
- Input tokens
- needs input
- Output tokens
- needs input
- Tool-call overhead
- needs input
per worker: input = calls × (instructions + payload + tool result) + replay; output = calls × tool-call output + one final answer; cost = (uncached input × input rate + cached input × cached rate + output × output rate) × batch × (1 + retry). run = workers × per worker. month = run × runs per day × 30. high = caching off, retry × 2, capped at 100%. Aggregated script: one call per worker, its summary read once as input, no replay. Comparison columns are per month. Savings: dreaming = month − month with instructions × (1 − instruction cut); Code Mode = (month − dreaming) × cost cut; PR review = PRs × (your cost − swarm cost), counted only when both are set; total = sum. Dollars round to cents (four decimals under $1); tokens round to whole numbers. Latency and rate-limit waits are not priced.
The calculator models scenarios; it does not measure yours. See the measured Code Mode case.
Inputs
Model input rate ($ / 1M tokens) — The vendor's price for input tokens. Editable, stamped with a retrieval date, linked to the vendor pricing page, in USD. If the vendor page differs from the default, trust the vendor page.
Model output rate ($ / 1M tokens) — The vendor's price for tokens the model writes. Same rule: editable, dated, linked to the source.
Tool calls per task — How many tool calls one task makes. Ten modest calls is a different bill than a hundred.
Payload size per call — Each call's input size, in tokens or characters. Dividing characters by four is a rough token approximation, not a conversion to bill against.
Tool result tokens per call — How much each tool result returns to the model. Charged as input on its first read and again on each replayed turn.
Tool-call output per call — Tokens the model writes to call each tool, such as the call's arguments. Charged at the output rate.
Final answer tokens — Tokens the model writes once per worker as its final answer. Charged at the output rate.
Workers — Agents running the task in parallel; each carries its own conversation.
Retry rate — Share of calls or tasks that fail and run again. Retries pay full price; the estimate multiplies by (1 + retry rate).
Runs per day / month — How often the task runs. A two-cent task daily and the same task every fifteen minutes are different budgets.
Context replay — How many earlier tool results are re-sent as input on each later turn. Often the largest line in the estimate; see context window management.
Prompt caching share — The share of input tokens eligible for the provider's cached-input discount. Only stable, repeated prefixes qualify — check OpenAI's or Anthropic's prompt-caching docs.
Batching — Whether independent calls run in one batched request where the provider offers it, instead of separate full-price calls.
Script aggregation — Whether N similar calls collapse into one script returning a summary. This is Code Mode's shape; the case below shows what it did to one job.
Instruction tokens per call — How many tokens your agent instructions send with every call. This is what dreaming shrinks, and we have no measured default, so the field starts blank.
Code Mode cost cut per run — Share of the workload cost that aggregating calls into one script removes. Default is 50%, measured on one daily triage job, not on the whole script catalog.
PRs per month — Pull requests your team reviews in a month. The PR review saving counts only when you set this and your cost per PR.
Your cost per PR review — What one review costs you today, in dollars. The calculator compares it with the swarm's cost per PR.
Swarm cost per PR review — Cost of one two-model triage run. Default is $0.02 per PR, measured on 14 PRs on 2026-10-21.
Instruction cut — Share of instruction tokens dreaming removes. Default is 52%, the average instruction cut over 28 nights.
Results
Input tokens — Tokens the model reads per run: payloads, each tool result read once, and replayed results. Assumes your replay count is honest; undercounting replay is the most common way real bills beat estimates.
Output tokens — Tokens the model writes per run: tool-call output plus one final answer per worker. Assumes tool-call output is roughly constant across calls.
Tool-call overhead — Tokens spent purely on the fan-out's shape: results re-sent by replay, plus everything retries re-run. Assumes overhead scales with call count and replay, not with the underlying work.
Orchestration / worker estimate — Cost from running multiple workers, each with its own conversation. Assumes workers split the work evenly and don't duplicate calls.
Monthly low-high range — Runs per month times the low and high single-run estimates. The low end uses your inputs; the high end doubles the retry rate (capped at 100%) and turns prompt caching off. Assumes the workload keeps the same shape all month.
Raw tool calls vs. aggregated script — The same scenario priced as N separate calls with their payloads and replay, versus one script call returning a summary. Assumes the summary is comparably useful — verify on your own data (measured Code Mode case).
Saving per lever — Amount each lever removes per month, shown as "needs input" until its fields are set. Assumes the measured defaults hold for your workload.
Saving per month and per year — The three lever savings added, then multiplied by 12. Assumes your workload and inputs stay the same all year.
Monthly spend today → with the swarm — Your workload spend plus your PR review spend, before and after the lever savings. Assumes your PRs per month and cost per PR are set.
Share of spend saved — Total saving divided by today's monthly spend. Assumes the workload has a cost; it can go negative when a review costs less than the swarm default.
Methodology and assumptions
Per worker, input = calls × (payload + tool result) + replay, with the cached share billed at the cached-input rate. Output = calls × tool-call output + one final answer. When batching is on, its discount applies to input and output. Retries multiply both by (1 + retry rate); workers and runs multiply the total. Replay and call count move the input column most. Latency is not modeled: wait time and rate limits sit outside the estimate.
Dreaming goes first: the monthly bill minus the same bill with instruction tokens cut by the default. Code Mode next: its cut applies to what dreaming leaves. PR review last: PRs per month times your cost per PR, minus the swarm's cost, counted only when both are set. Levers apply in that order so no token counts twice. The 52% default is our measured instruction cut, not the simulated 25 to 40% share of our token drop. Dreaming's own nightly run cost is not subtracted.
The calculator models scenarios; it does not measure yours, and modeled numbers are only as good as their inputs. Keep measured and modeled separate: the only real numbers on this page are our three measurements, each from one of our posts. They are the Code Mode case, two-model PR review and dreaming instructions. Model prices change without notice, so the default rates carry a retrieval date and a link — if the vendor page disagrees with the field, the field is wrong. For where agent costs come from, see the cost of AI agents; for the replay mechanic, see context window management. On Agent Swarm Cloud you bring your own model keys: model spend is billed by your provider, not us (pricing).
One measured case
One production triage job ran 26 underlying tool calls. Moving the data-gathering into a script collapsed them into one script call: 25,811 characters reached the model, against a modeled ~3.26M on the raw path — about 99.2% fewer characters for that one data-gathering step, modeled raw path versus measured script run. The script path measured 13.12 seconds. End to end, the recurring job using this triage went from roughly five minutes to 1–2 minutes and cost roughly half per run.
Both labels matter: 99.2% is one step of one job; roughly half is that job's end-to-end number. Neither is a typical saving, and neither is promised for your workload — the full measured-versus-modeled breakdown is in the Code Mode post.
Ways to cut the number
- Aggregate calls into scripts. One script returning a summary replaces N payloads and their replay — the biggest lever here, and the one with a measured case behind it.
- Trim payloads before they re-enter context. A result replayed every turn is paid for every turn; summaries and filtering pay back on the replay factor.
- Use prompt caching for stable prefixes. Repeated instructions and schemas can ride the cached-input discount; set the caching share only as high as your prefixes actually repeat.
- Batch independent calls. Calls that don't depend on each other can go in one batched request instead of several full-price round trips.
- Cap retries. Every retry re-pays input and output; a retry budget bounds the failure loop.
- Split work across workers with scoped context. More workers without scoped context can raise total spend; each worker should see only its slice.
FAQ
How do I reduce token costs when my agent calls many tools? Cut what the fan-out re-sends: aggregate similar calls into one script returning a summary, trim results before they re-enter context, replay fewer prior results per turn. The side-by-side column shows the gap (measured case).
Does prompt caching lower agent costs? It can, on the share of input that is a stable, repeated prefix — instructions and schemas, not fresh tool results. Both OpenAI and Anthropic discount cached input; the calculator prices only what you mark eligible.
Why do multi-tool agents cost more than single prompts? Every tool call adds input you pay to read, output you pay to write, and — if the result is kept — a payload you re-pay on later turns. A single prompt pays once; a 26-call fan-out can pay for the same bytes many times.
Is this estimate what I'll actually be billed? No. It models your workload from the inputs you give it; the provider bills what happens. Treat the single-run number as a lower bound, and re-check the model rates against the vendor's pricing page.
What does Agent Swarm save on token cost and PR review? Code Mode cut per-run cost by roughly half on one daily triage job, not the whole script catalog (post). Two-model PR review cost $0.26 for 14 PRs, about $0.02 each (post). Dreaming made agent instructions 52% shorter on average (post). Each default is a number we measured in our own posts.