AI Agent Cost Calculator

Most LLM calculators price a single request. Agents make dozens of calls per task, and context grows with every call. Model the real cost of your agent loop, including prompt caching, retries, and sub-agents.

tok
tok

Model calls per task

tok

Reasoning + tool call

tok
%

Bill repeated history at the cache-hit rate

Steady traffic keeps the system prompt cached between runs

Each runs its own loop with the same per-step sizes

Cost per run
$0.20
incl. retries
Per day
$100.96
500 runs
Per month
$3,029
30 days
Tokens per run
336.7K
final context 33.1K
Tokens billed at each step of one run (Claude Sonnet 5)

Every step re-sends the whole conversation, so input grows linearly per step and total input grows quadratically with the number of steps.

Ways to cut this cost
  • This 15-step run costs 28× a single call, because every step re-reads the growing history. Fewer, larger tool calls (or parallel tool calls) keep the step count down.
20 rows
The same agent on every model
GPT-6 Luna
OpenAI
$0.0093$4.67$140.150.05×
GPT-5 mini
OpenAI
$0.03$14.18$425.380.14×
Gemini 3.5 Flash-Lite
Google
$0.03$17.35$520.450.17×
Gemini 2.5 Flash
Google
$0.03$17.35$520.450.17×
Gemini 3.8 Flash
Google
$0.07$35.04$1,0510.35×
GPT-5.4 mini
OpenAI
$0.08$37.54$1,1260.37×
Claude Haiku 4.5
Anthropic
$0.10$50.48$1,5140.50×
Gemini 2.5 Pro
Google
$0.14$70.90$2,1270.70×
Gemini 3.5 Flash
Google
$0.15$75.08$2,2520.74×
GPT-6 Sol
OpenAI
$0.19$93.43$2,8030.93×
Gemini 3.1 Pro (preview)
Google
$0.20$100.10$3,0030.99×
Claude Sonnet 5selected
Anthropic
$0.20$100.96$3,0291.00×
GPT-5.4
OpenAI
$0.25$125.13$3,7541.24×
GPT-4.1
OpenAI
$0.26$131.75$3,9531.30×
Claude Sonnet 4.6
Anthropic
$0.30$151.44$4,5431.50×
Claude Opus 5.5
Anthropic
$0.34$171.93$5,1581.70×
GPT-5.5
OpenAI
$0.50$250.25$7,5082.48×
Claude Opus 5
Anthropic
$0.50$252.40$7,5722.50×
Claude Fable 5.1
Anthropic
$0.78$392.35$11,7703.89×
GPT-6 Astra
OpenAI
$0.93$467.17$14,0154.63×
Step-by-step table
15 rows
Tokens and cost at each step of one run on Claude Sonnet 5
16,5006,0005000400$0.00653.5%
28,4006,5001,9000400$0.015.5%
310,3008,4001,9000400$0.015.7%
412,20010,3001,9000400$0.015.9%
514,10012,2001,9000400$0.016.2%
616,00014,1001,9000400$0.016.4%
717,90016,0001,9000400$0.016.6%
819,80017,9001,9000400$0.016.8%
921,70019,8001,9000400$0.017.0%
1023,60021,7001,9000400$0.017.2%
1125,50023,6001,9000400$0.017.4%
1227,40025,5001,9000400$0.017.6%
1329,30027,4001,9000400$0.017.8%
1431,20029,3001,9000400$0.018.0%
1533,10031,2001,9000400$0.018.2%

Anthropic cache writes use the 5-minute rate (1.25× input). OpenAI and Gemini bill cache writes as normal input, and Gemini's hourly cache storage isn't included. Prices last checked 2026-09-25.

The math behind agent costs

An agent loop repeats: the model reads the context, emits a tool call, your code runs the tool, and the result is appended. At step i the model reads:

context(i) = system_prompt + tools + task + (i − 1) × (output_per_step + tool_result_per_step)

Summed over N steps, input tokens grow with N². Doubling the number of steps roughly quadruples input cost, which is why step count and tool-result size matter more than almost any other design choice.

How caching is modelled

  • Step 1: the system prompt is read from cache if it's already warm from earlier runs. Otherwise the whole prompt is written to the cache.
  • Every later step: everything up to the previous step is a cache hit, and only the newly appended output and tool result are written.
  • Anthropic charges 1.25× input for 5-minute cache writes and 0.025–0.1× for reads, depending on the model. OpenAI and Gemini cache automatically, with no write premium.

Design choices that change the bill

  • Keep tool results small. Return IDs, snippets, and summaries. Let the agent ask for more.
  • Batch tool calls. Parallel tool calls in one step avoid an extra round trip that re-reads the whole context.
  • Clear or compact old context. Dropping stale tool results or summarizing history stops the quadratic growth.
  • Route by difficulty. A frontier model for planning with cheaper sub-agents for reading and extraction is often the best cost-quality mix.
  • Measure cost per completed task. A cheaper model that needs twice the steps or fails more often is not cheaper.

Frequently asked questions

Why do AI agents cost so much more than a single LLM call?

An agent calls the model many times per task, and each call re-sends the entire conversation so far: system prompt, tool definitions, every previous tool call, and every tool result. Context grows with each step, so total input tokens grow roughly with the square of the number of steps. A 20-step agent can easily cost 50–100× a single call.

How does prompt caching reduce agent costs?

Because each step's prompt starts with the previous step's prompt, almost all input on every step is a cache hit. With caching, only the newly appended output and tool result are billed at full (or cache-write) price, and the rest at the cached rate, often 90% cheaper. For long agent loops, caching commonly cuts the input bill by 70–90%.

How many steps does a typical agent take?

Simple tool-use tasks (look something up, then answer) take 2–5 steps. Research and coding agents commonly take 10–50 steps, and long-running autonomous tasks can run to hundreds. Log real traces to measure your own distribution. The average hides expensive long runs.

Are sub-agents cheaper than one long agent loop?

Often, yes. A sub-agent starts with a fresh, short context, so it doesn't pay to re-read the main agent's whole history, and it can run on a cheaper model. It returns only a summary to the parent. The trade-off is extra system-prompt tokens per sub-agent and some coordination overhead.

What's not included in this estimate?

Server-side tool fees (such as web search at $10 per 1,000 searches on Claude), hosted sandbox or runtime fees, Gemini's hourly cache storage, long-context surcharges, batch discounts, and the provider's hidden tool-use system prompt (a few hundred tokens). Use it for order-of-magnitude planning, then check against real usage logs.

Related reading

More AI builder tools

  • LLM Token Counter — Count tokens for GPT, Claude, and Gemini, check context-window fit, and see what the prompt costs.
  • LLM API Cost Calculator — Compare per-request and monthly API costs across OpenAI, Anthropic, and Google models, with prompt caching.
  • LLM VRAM Calculator — Estimate GPU memory for weights, KV cache, and fine-tuning, and see which GPUs a model fits on.