CostMonStart free

Guide

The AI agent cost guide: why agentic AI blows up your bill

A single API call and a 200-step agent loop don't just differ in call count — they differ in how fast cost compounds. Here's the worked math, and how to catch it before the invoice does.

Worked examples below use Claude Sonnet 5, a Balanced-tier model. Per-token figures come from the LLM pricing data, verified as of 2026-07-08; this page's scenario figures were checked as of 2026-07-19. See the full LLM API pricing reference for every model and provider.

The argument, in one table

Cost climbs faster than step count

Each step re-sends everything said so far, so input tokens — and cost — grow faster than the number of steps. The runaway row has no ceiling on step count at all.

Cost per run and per 1,000 runs, by agent scenario, priced against Claude Sonnet 5
ScenarioStepsInput tokensOutput tokensCost per runCost per 1,000 runs
Single callOne request, one response — the baseline every other row is measured against.1800400$0.0084$8
Short tool-use agentA handful of tool calls — search, fetch, read a file — each one re-sending everything said so far.513,0001,500$0.0615$62
Task / coding agentA multi-file coding or research task — reading, editing, and re-reading its own prior output.20219,0007,000$0.762$762
Multi-agent fan-outOne task split across several sub-agents running the same tool-use pattern in parallel.1050,5003,000$0.9825$983
Runaway loopno ceilingThe horror case CostMon exists to catch — a loop with no per-run step ceiling, still going.20018,390,00070,000$56.22$56,220

See how each row's figures were derived in the assumptions below — every number here comes from the same open formula: input tokens grow with step count, priced at Claude Sonnet 5's published rate. The runaway row isn't hypothetical — see real, cited AI-agent bills that ran into six and seven figures before anyone noticed.

Why it happens

Why agents blow up your bill

The full context gets re-sent every step

A single API call bills once. An agent step bills once per step, and every step re-sends the entire transcript so far — the original task, every prior tool result, every reply — as new input tokens. Input cost grows with the square of the step count, not linearly, because each of the N steps re-sends roughly N times as much accumulated context as the first one did.

Tool results balloon the input side, not the output side

A search result, a file read, or an API response gets pasted back into context as input tokens on the next step, and it's usually far larger than anything the model itself generated. A run heavy on tool use can carry an input-to-output ratio many times wider than a plain chat conversation, which matters because most people budget for AI cost by estimating output length alone.

Retries and back-off multiply the call count

A tool call that times out, a rate limit that triggers a retry, or a step the agent redoes after a bad result all add full extra steps — each one re-sending the same accumulated context again. A retry rate that looks trivial in isolation compounds with everything above it.

Parallel fan-out multiplies the whole run, not just one step

Splitting a task across several sub-agents is often the right call for latency or coverage, but it multiplies total cost by however many agents are running, on top of whatever each individual agent's step count already costs. Five parallel agents at the same per-agent cost is a 5x bill, not a rounding error.

There's usually no default ceiling on steps or tokens

A plain API integration has a natural cap: one request in, one response out. An agent loop has no equivalent default — nothing stops it at step 20 instead of step 200 unless something is explicitly built to stop it. Absent a ceiling, a bug, a bad prompt, or an edge case the agent can't resolve turns into an open-ended loop that keeps re-sending an ever-larger context until something else intervenes.

How to fix it

How to keep agent cost under control

Set a per-run step and token budget

Cap how many steps a single run is allowed to take and how many total tokens it can consume before it's forced to stop and report back, rather than continuing indefinitely. A budget that's hit is a signal to look, not a silent failure — far cheaper than a loop that runs unbounded.

Route by tier: Fast for sub-tasks, Frontier only where it earns its cost

Most steps in a multi-step run — summarizing a tool result, checking a simple condition, formatting output — don't need a Frontier-tier model. Reserving the most capable (and most expensive) tier for the steps that genuinely require it, and routing the rest to a Fast-tier model, can cut the per-step rate substantially without changing the run's step count at all.

Use prompt caching on the stable prefix

The system prompt, tool definitions, and task description usually stay identical from step to step even as the rest of the context grows. Caching that stable prefix means the provider charges a small fraction of the normal input rate for re-processing it on every subsequent step, which matters most exactly on the long, many-step runs this page is about.

Batch what doesn't need to run synchronously

Runs that don't need an immediate interactive response — a scheduled sweep, a bulk classification job — are often eligible for a provider's batch API at a meaningfully lower per-token rate than the standard synchronous endpoint, for the same total work.

See it in a daily view, not a month-end invoice

Every control above still assumes someone notices when it's not working — a budget nobody reads is just a number in a config file. A daily, normalized view of AI spend sitting next to the rest of the stack, with anomaly alerting on top of it, catches a runaway agent within a day or two of it starting instead of at the end of the billing period, when the only remaining option is damage control.

FAQ

Common questions about AI agent cost

Why does an AI agent cost so much more than a single API call?

A single call bills once, for one prompt and one reply. An agent run is many calls chained together, and — unlike a plain conversation — most of those calls re-send the entire accumulated transcript and every prior tool result as new input tokens. That makes input cost grow much faster than the step count itself: doubling the number of steps typically more than doubles the total cost, not just doubles it.

How do I cap agent costs?

The most direct lever is a per-run ceiling — a maximum step count and a maximum total token budget the run isn't allowed to exceed before it has to stop and report back. Beyond that, routing easy sub-tasks to a cheaper model tier, caching the stable parts of the prompt, and batching non-interactive work all reduce the rate without touching the ceiling itself.

What's the actual math behind the scenario table above?

At step k, that step's input is the base prompt plus k times the per-step growth (everything re-accumulated so far); its output is a roughly constant per-step amount. Summing input and output across every step, pricing each side at a model's published per-token rate, and multiplying by however many agents run in parallel gives the cost of one full run — the same formula for every row in the table, just with different step counts and growth rates.

How do I track what my agents actually spend?

The figures on this page are a planning model built from published list prices, not a bill. CostMon connects directly to your provider's cost API (starting with the Anthropic Admin cost report) and normalizes real AI spend into the same daily dashboard as your cloud and SaaS costs, so a runaway agent shows up as a spike in a number you're already watching, not a surprise at the end of the month.

See what your stack really costs.

Connect your first providers in minutes and give finance and engineering one number they both trust. Flat pricing — never a percentage of your bill or your savings.

Esc