AI & LLM Economics

AI Agent Cost Calculator (Cost per Successful Task)

An agent is not one API call — it is a loop. Every step re-sends the system prompt, the tool definitions, and the growing conversation history, so the average input per step is large and the bill compounds with each extra step. And the dashboard only shows you cost per run: if the agent produces a usable result 60% of the time, every success also carries the cost of the failures around it, and the real unit cost is 1.67× what the dashboard says. Enter the steps per run, the average tokens per step, the model, your run volume, and an honest success rate; the calculator returns cost per run, the monthly bill, and the number that actually matters — cost per successful task — plus how much of the month's spend is burned on runs that produce nothing.

The agent loop

Agents re-send the system prompt, tool definitions, and growing history at every step, so the average input per step is typically high — tens of thousands of tokens, not hundreds.

Model & caching

Volume & reliability

Cost per successful task

$0.75

$0.45 per run × 1.67 — every success carries the failed runs around it

Cost / run

$0.45

Monthly cost

$1,350.00

Wasted / mo

$540.00

Cost detail
Input tokens / run200,000Output tokens / run8,000Input cost / run$0.33Output cost / run$0.12Cost per run$0.45Daily cost$45.00Monthly cost (30 days)$1,350.00Productive spend / mo$810.00Wasted on failed runs / mo$540.00Cost per successful task$0.75

Dashboard cost vs true unit cost

Per runPer successful task

Compare scenarios

Run the same calculation with two or three input sets side by side. Differences are highlighted; every number comes from the same tested formula as the calculator above.

InputScenario AScenario B
Steps Per Run
Input Tokens Per Step
Output Tokens Per Step
Model Id
Runs Per Day
Success Rate Pct
Cache Hit Rate Pct

How it works

Cost per run = steps × average tokens per step × the model's price per million tokens, input and output priced separately. Input dominates in agents because context re-accumulates: at the defaults, 10 steps × 20,000 input tokens is 200,000 input tokens per run against only 8,000 output tokens. If you set a prompt-cache hit rate, that share of input is priced at the provider's published cached-input rate — 90% off list for the models that offer it. At a 50% hit rate on Claude Sonnet 4.6 the blended input price is $1.65 per million instead of $3, and one run costs $0.33 of input plus $0.12 of output: $0.45.

Cost per successful task = cost per run ÷ success rate. This is the honest unit economics of an agent: at 60% success, each usable result absorbs its own run plus two-thirds of a failed one, so $0.45 per run becomes $0.75 per successful task — a 1.67× multiplier that never appears on a billing dashboard. The multiplier is pure arithmetic (100 ÷ success rate): 90% success costs you 1.11×, 50% costs 2×, 30% costs 3.33×. Improving reliability is often worth more than switching to a cheaper model.

Monthly bill = cost per run × runs per day × 30, split into productive and wasted spend. At 100 runs a day the default agent bills $1,350 a month, of which $540 — the failed 40% — buys nothing. The chart puts cost per run next to cost per successful task so the gap is visible. If the selected model publishes no cached-input price, the cache hit rate is ignored (treated as 0%) and the calculator says so rather than silently inventing a discount.

Frequently asked questions

How do I estimate tokens per step for my agent?+

Measure — don't guess. Token counts per step vary enormously with the framework, the tool definitions, and how aggressively history is truncated or summarized: the same task can cost 5,000 or 50,000 input tokens per step depending on scaffolding. Most provider dashboards and observability tools report input/output tokens per request; run a handful of representative tasks and average them. Remember the input side grows with each step because the whole context is re-sent — use the average across all steps of a run, not the first step's count. Prices and caching behavior are as of the pricing snapshot shown by the tool (2026-07) — verify against the provider's current pricing page.

What counts as a successful run, and what about retries?+

A success is a run whose output you actually use without redoing the work — a resolved ticket, a merged change, a correct extraction. Be honest: 'finished without crashing' is not success if a human then repeats the task. This calculator divides cost per run by that rate to price each usable result. Automatic retries and fallbacks to a bigger model are NOT modeled separately — if your system retries failed runs, count each retry as its own run in runs per day, otherwise the monthly bill and the waste figure will understate reality.

Why is my cache hit rate being ignored?+

Because the model you selected does not publish a cached-input price, so there is no discounted rate to apply — the calculator prices all input at the full list rate and shows a note instead of inventing a discount. As of the 2026-07 snapshot, the OpenAI, Anthropic, and Google models listed here publish cached-input prices at roughly 90% off list; the Together AI Llama endpoints listed do not. Caching also is not free by default everywhere: Anthropic, for example, charges a premium to write the cache (about 1.25× input for the 5-minute cache), which this calculator does not model — verify the provider's caching docs before relying on the saving.

Related tools

Sources

Embed this calculator

+

Drop this calculator into your own site — free. Keep the credit link below the frame: it’s how the free embed stays free.