AI Agent Cost Calculator
The true cost of LLM agent loops — context grows quadratically with step count. Calculate per-task and monthly team spend for Claude Code, RAG agents, and custom pipelines.
- Enable prompt caching — saves $0.0831 per task on the static prefix
- Trim system prompt — each 500 tokens removed saves $0.002500 per task
- Cap loop steps at N=10 — saves $0.0831 per task (quadratic effect)
- Truncate tool results — each 500 tokens removed from R saves $0.0238
- Route simple steps to a cheaper model → Model Routing Calculator
- Self-host at this volume? → Self-Host vs API Calculator
| Model | Provider | Cost/task | In $/M | Out $/M |
|---|---|---|---|---|
| GPT-4o mini | OpenAI | $0.0664 | $0.15 | $0.6 |
| GPT-5 mini ← current | OpenAI | $0.1187 | $0.25 | $2 |
| o4-mini | OpenAI | $0.4873 | $1.1 | $4.4 |
| GPT-4o | OpenAI | $1.11 | $2.5 | $10 |
| GPT-5.4 | OpenAI | $1.15 | $2.5 | $15 |
| Claude Sonnet 5 | Anthropic | $1.35 | $3 | $15 |
| Claude Opus 5 | Anthropic | $2.26 | $5 | $25 |
| o3 | OpenAI | $4.43 | $10 | $40 |
Prices verified 2026-08-20 · Download dataset · Methodology
How to Use
Describe your agent shape
Enter system prompt size, initial task tokens, and the average output and tool result tokens per step. These define how fast context grows.
Set loop steps
Use the slider to set how many steps your agent takes per task. Watch how cost grows — doubling steps roughly quadruples input cost (it's quadratic, not linear).
Choose a model
Select from 30+ live-priced models. Enable caching if your agent re-sends the same system prompt and context on every step.
Scale to your team
Enter tasks per developer per day, number of developers, and working days per month to get a real monthly team cost.
Why agent costs grow quadratically
In an N-step agent loop, the input context at step i contains the system prompt (S), the initial task (T₀), and every previous assistant output and tool result. Let G = A + R (tokens gained per step). Then:
Total input tokens = N·(S + T₀) + G·N·(N−1)/2
↑ linear ↑ quadratic
Doubling steps from 10 → 20:
linear part doubles (×2)
quadratic part grows (×4)
→ Overall input cost roughly quadruples at high NThe quadratic term is why a 20-step Claude Code session costs far more than twice a 10-step session. The key levers: cap loop steps, trim system prompt tokens, summarize or truncate tool results before injecting them, and enable prompt caching on the static prefix.
See the full derivation on the methodology page.
How to Cut This Cost
Enable prompt caching — the system prompt and static context are re-read at 10% of full price on every subsequent step.
Cap loop steps. Reducing N from 20→10 cuts input by ~75% (quadratic savings), not just 50%.
Summarize or truncate tool results before injecting them into context. Trim file reads to only relevant lines.
Route simple sub-tasks to a cheaper model (GPT-5 mini / Haiku 4.5) and reserve the expensive model for the orchestration layer.
FAQ
Have more questions? Contact us
Last verified: 2026-08-20 · methodology · data sources