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.

Agent Cost Calculator
Quick presets
Agent Shape
Model
Scale
Cost per task
$0.1187
Solo dev / month
$130.63
Team / month (1 devs)
$130.63
Total tokens / task
419.0k
Quadratic cost breakdown: You are paying for your 2,000-token system prompt 20 times — that's 40,000 tokens (9.7% of total input). The quadratic term (context growth) accounts for $0.0902 vs $0.0125 linear.
Cumulative input cost per step (first 15 steps)
$0.000625
S1
$0.001725
S2
$0.003300
S3
$0.005350
S4
$0.007875
S5
$0.0109
S6
$0.0143
S7
$0.0183
S8
$0.0227
S9
$0.0276
S10
$0.0330
S11
$0.0388
S12
$0.0452
S13
$0.0520
S14
$0.0592
S15
How to cut this cost
  1. Enable prompt caching — saves $0.0831 per task on the static prefix
  2. Trim system prompt — each 500 tokens removed saves $0.002500 per task
  3. Cap loop steps at N=10 — saves $0.0831 per task (quadratic effect)
  4. Truncate tool results — each 500 tokens removed from R saves $0.0238
  5. Route simple steps to a cheaper modelModel Routing Calculator
  6. Self-host at this volume?Self-Host vs API Calculator
Same agent across models (cheapest first)
ModelProviderCost/taskIn $/MOut $/M
GPT-4o mini OpenAI$0.0664$0.15$0.6
GPT-5 mini ← currentOpenAI$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 N

The 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

Up to 90%

Enable prompt caching — the system prompt and static context are re-read at 10% of full price on every subsequent step.

Up to 70%

Cap loop steps. Reducing N from 20→10 cuts input by ~75% (quadratic savings), not just 50%.

Up to 50%

Summarize or truncate tool results before injecting them into context. Trim file reads to only relevant lines.

Up to 80%

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