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
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
| Step | Input tokens | of which cached | Output tokens | Cost |
|---|---|---|---|---|
| 1 | 3,500 | 0 | 300 | $0.01 |
| 2 | 5,080 | 4,064 | 300 | $0.0054 |
| 3 | 6,660 | 5,328 | 300 | $0.0062 |
| 4 | 8,240 | 6,592 | 300 | $0.0070 |
| 5 | 9,820 | 7,856 | 300 | $0.0077 |
| 6 | 11,400 | 9,120 | 300 | $0.0085 |
| 7 | 12,980 | 10,384 | 300 | $0.0092 |
| 8 | 14,560 | 11,648 | 300 | $0.010 |
| Total | 72,240 | 54,992 | 2,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?
| Steps in the task | Input at the last step | Total input across the task | Total ÷ first call |
|---|---|---|---|
| 1 | 3,500 | 3,500 | 1× |
| 4 | 8,240 | 23,480 | 6.7× |
| 8 | 14,560 | 72,240 | 20.6× |
| 16 | 27,200 | 245,600 | 70.2× |
| 32 | 52,480 | 895,680 | 255.9× |
How to estimate what an AI agent will cost
- 1Count 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.
- 2Measure 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.
- 3Set 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.
- 4Read 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?
How much does prompt caching save in an agent loop?
Do tool definitions count as input tokens?
Should I count reasoning tokens?
What retry percentage should I use?
Can I use the Batch API for an agent?
Sources
- OpenAI API pricing (checked 20 Oct 2026)
- OpenAI deprecations (checked 20 Oct 2026)
- Anthropic Claude pricing (checked 20 Oct 2026)
- Gemini Developer API pricing (checked 20 Oct 2026)
- FBIL USD/INR reference rate, 2026-10-19 (RBI website) (checked 20 Oct 2026)
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