AI agent cost estimator: cost per task and per month

An agent re-sends its whole context on every step, so input tokens grow with each tool call and a task costs far more than one request. Enter the steps, tokens per step, cache share and tasks a month to see the per-step token table and the monthly cost on each model.

Updated

One step is one request to the model: it reads the whole context so far and answers or calls a tool.

tokens

Sent again on every step. Each tool's name, description and schema counts.

tokens
tokens

The tool-call JSON or the reply, plus any reasoning tokens billed as output.

tokens

Search hits, file contents or API responses that go back into the context.

tokens

Wrapper tokens around each call and result. 80 is our assumption; measure yours.

%

Step 1 is always a full-price read. A stable prefix that grows by appending usually caches well.

%

Share of the cost repeated when a step is retried or a task is run again.

FBIL reference rate on 2026-10-19.

Claude Sonnet 5.5: 5,000 tasks a month, 8 steps each

$335.97

$0.07 a task · about ₹31,840 a month

Input tokens in one task
72,240step 1 sends 3,500, step 8 sends 14,560
Output tokens in one task
2,400
Input as a multiple of the first step
20.6×what the loop costs over a single call
Saved by the prompt cache
$548.55per month, against the same loop with no caching
Cheapest model for this loop
Google · Gemini 2.5 Flash-Lite$16.98 a month
Tokens and cost for each step of one task (Claude Sonnet 5.5, before the retry uplift)
StepInput tokensof which cachedOutput tokensCost
13,5000300$0.01
25,0804,064300$0.0054
36,6605,328300$0.0062
48,2406,592300$0.0070
59,8207,856300$0.0077
611,4009,120300$0.0085
712,98010,384300$0.0092
814,56011,648300$0.010
Total72,24054,9922,400$0.06
  • Assumptions: step k sends the system prompt, the task and everything earlier steps added (output + tool result + overhead). Step 1 is a full-price read; later steps read 80% from the cache. Retries add 5% to the cost. Prices checked 2026-10-20.
  • Every model on the same loop, cheapest first: Gemini 2.5 Flash-Lite $16.98; GPT-6 Luna $18.24; Claude Haiku 5.5 $18.24; GPT-4.1 nano $21.31; GPT-4o Mini $42.80.
  • Cache reads are priced. Writing new tokens into the cache costs extra on Claude and GPT-6 models and is not included, so cached savings here are a little optimistic.

How is the cost of an AI agent run calculated?

An agent is a loop. Each step is a request to the model, and the API is stateless, so every request re-sends the whole conversation so far: the system prompt and tool definitions, the task, and what every earlier step added. That means input grows with each step, and the total input over a task is far more than the final context size. With a fixed prefix P and each step adding A tokens (the model's output, the tool result and the call overhead), step k sends P + (k − 1) × A input tokens.

Cost per step is fresh input × input price + cached input × cached price + output × output price, all per million tokens. Prompt caching is what makes loops affordable: the prefix repeats on every call, so vendors bill cache reads at a fraction of the input price. This tool treats step 1 as a cold read and applies your cached share to later steps. Models with long-context pricing switch to higher rates for the whole request once a step's input crosses their threshold, and this tool applies that per step.

Retries are an uplift on the total: a tool error, a malformed answer or a task re-run repeats steps you already paid for. This tool is different from a per-request calculator because it models that growth. If your feature makes one call per user action, use the LLM API cost calculator instead.

input at step k = system + task + (k − 1) × (output + tool result + overhead)
step cost = (fresh × input price + cached × cache price + output × output price) ÷ 1,000,000
monthly = Σ step costs × (1 + retry %) × tasks a month

For one request per user action rather than a loop, use the LLM API cost calculator.

Real per-scan token costs from our own apps are on measured AI costs from apps we built.

How much does context growth add over a single call?

Input growth for a 3,500-token prefix where each step adds 1,580 tokens (no caching)
Steps in the taskInput at the last stepTotal input across the taskTotal ÷ first call
13,5003,5001×
48,24023,4806.7×
814,56072,24020.6×
1627,200245,60070.2×
3252,480895,680255.9×

How to estimate what an AI agent will cost

  1. 1
    Count the stepsRun the task a few times in a test and log how many model calls it takes. Use the average, then check the 90th percentile; the long tasks cost the most.
  2. 2
    Measure the tokensUse the usage field in each API response for the system prompt size, the tool results and the output per step. Your vendor's dashboard shows the same totals.
  3. 3
    Set the cache shareIf the system prompt and earlier turns stay identical between steps, most of the input is cacheable; check your usage data for cache-read tokens and enter that share.
  4. 4
    Read the per-step tableThe table shows where the tokens go. If the last steps cost many times the first, trim tool results or summarise old turns.

Frequently asked questions

Why does an agent cost so much more than one API call?
Because each step re-reads everything that came before it. A task with 8 steps does not pay for the context once, it pays for step 1's context, then step 2's, and so on, so input tokens grow roughly with the square of the number of steps unless caching or trimming holds it down.
How much does prompt caching save in an agent loop?
It depends on the share of each step's input that is an unchanged prefix. Cache reads are priced well below fresh input: on Claude Sonnet 5.5 the rates file lists $0.10 against $2.00 per million tokens, so at 80% cached, input on steps 2 and later costs about 28% of the uncached figure. The panel in the result shows the saving against the same loop with no caching.
Do tool definitions count as input tokens?
Yes. Every tool's name, description and JSON schema is part of the prompt, and it is sent on every step. Thirty detailed tools can add thousands of tokens to each request, which is why they belong in the cached prefix.
Should I count reasoning tokens?
Yes if your model bills them. The vendor pricing pages treat reasoning as output, so add them to the output per step. A model that thinks for 2,000 tokens before each tool call costs several times more per step than the same model with short outputs.
What retry percentage should I use?
Use your own failure data: the share of steps that error or get re-run. If you have none, 5 to 10 per cent is a reasonable starting guess for a tool-using agent, but that is an assumption, not a published figure.
Can I use the Batch API for an agent?
Only for steps that can wait up to a day for a result. A loop where step 2 depends on step 1's answer needs a result before it continues, so batch fits overnight pipelines, not interactive agents.

Sources

Related tools

See all 135 free tools

Building a SaaS product?

We design, build, and scale SaaS platforms — from auth and billing to dashboards and APIs.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter