The short version
An agent is not a chatbot with tools. It is a loop that re-sends its entire accumulated state on every single turn, and the bill grows with the square of the conversation, not the length of it.
Most teams discover this the way Microsoft did — from finance, not from engineering. What follows is the arithmetic, the published numbers, and the levers that actually move them.
An agent loop re-sends the whole conversation on every turn. Tool definitions, prior tool results, prior thinking, file contents — all re-billed as input, every call. Cost grows quadratically with turn count, not linearly.
A 2026 analysis of agent trajectories across eight frontier models on SWE-bench Verified put a number on it: agentic coding tasks consume roughly 3,500× more tokens than a single-round code-reasoning question, and about 1,200× more than coding chat.
The intuition is that output is expensive, so output must drive the bill. In agents it does not. The same analysis found cache reads dominate both token volume and dollar cost in every phase of a trajectory. In its own words: output tokens are individually priced roughly 80× higher than cache reads, and yet "the sheer volume of accumulated context is large enough that cheap-per-token cache reads still outweigh expensive-per-token output in aggregate".
Which reframes the whole optimisation problem. You are not paying for what the agent says. You are paying, over and over, for what it has already read.
The same study found accuracy peaks at intermediate cost and then declines: higher output-token usage correlates with lower task accuracy. A model burning tokens is usually a model thrashing — looping, re-reading, second-guessing. The expensive run is often the failing run.
The trajectory analysis is specific: cost spikes are driven by file views, test execution, script generation and the final summary. A single cat of a large file can add tens of thousands of tokens that you then re-pay for on every subsequent turn of the session.
Anthropic publishes its own Claude Code figures, and they are the most trustworthy anchor available because they come from the vendor's own telemetry rather than a survey.
| Source | Figure | Context |
|---|---|---|
| Anthropic (own docs) | ~$13 per developer per active day | Average across Claude Code users |
| Anthropic (own docs) | $150–250 per developer per month | Typical monthly cost |
| Anthropic (own docs) | 90% of users under $30 on any active day | The distribution is heavily skewed |
| Anthropic (own docs) | $500–2,000/month | Power users running heavy automation |
| Microsoft (reported) | ~$2,000 per engineer per month | Led to moving engineers to a $39/seat flat-rate tool |
| Uber (reported) | 2026 AI budget exhausted in 4 months | Same category of spend |
| Developer self-reports (Hacker News) | $40/day · $250 in 3 weeks · $15,000 in one month | Anecdotal, unaudited — but the spread is the story |
The Microsoft comparison is the one that gets repeated in budget meetings, and the arithmetic is brutal: roughly $2,000 per engineer per month in token billing against $39 flat for a seat-priced alternative. Whatever you think of the trade-off, that is a 51× ratio, and no CFO ignores a 51× ratio.
The interesting failures are not "we used it a lot". They are cases where the bill decoupled from the work.
A March 2026 Hacker News thread asking engineers what they spend produced answers ranging from $40/month to $15,000/month, in the same thread, for ostensibly similar work. One reply: "I've spent $15,000 this month. Most of it isn't code, I'm vibe coding a K8s cluster from scratch and having endless discussions trying to debug network latency."
Another engineer reported a steady run rate of roughly $4,200 a year with days ranging from under $10 to $40. The variance inside one person's usage is larger than the difference between most tools.
The best-documented blow-up, and the one worth understanding in detail, was published on Hacker News in January 2026 by a developer cancelling two Cursor Ultra subscriptions.
His spend went from a steady $60–100/month to $500+ in a few days, projecting to roughly $1,600/month, with no change in how he worked. He instrumented a single call:
| Component | Tokens |
|---|---|
| Actual user input | ~4,000 |
| Cache read tokens | ~21,000,000 |
| Total billed | ~22,000,000 |
| Cost of this single call | ~$12 |
His diagnosis, in his own words: "Claude never attended to 21M tokens. I still paid for them." The tool had built a large hidden prompt state — history, tool traces, agent state, reasoning, codebase context — cached it, and replayed the entire cached prefix on every call, billing cache-read tokens each time, including for content that was summarised or truncated before the model ever saw it.
His conclusion is the sentence every agent team should internalise: "You think you are operating inside a 200k window, but you are paying for a much larger hidden history being replayed over and over."
Parallel agents feel like a performance trick. They are a cost decision.
Anthropic published the numbers from its own multi-agent research system: agents typically use about 4× more tokens than chat interactions, and multi-agent systems use about 15× more tokens than chat. Their own conclusion: "For economic viability, multi-agent systems require tasks where the value of the task is high enough to pay for the increased performance."
Separately, Anthropic's Claude Code documentation states that agent teams use approximately 7× more tokens than standard sessions, because each teammate maintains its own context window and runs as a separate instance. Agent teams are disabled by default, and that default is a pricing decision as much as a safety one.
The same Anthropic write-up reports the multi-agent system outperformed a single-agent Opus baseline by 90.2% on their internal research evaluation, and that token usage alone explained 80% of performance variance. So the multiplier buys something real — on research-style tasks with genuinely parallel subproblems.
They are equally clear about where it does not: coding is a poor fit, because "most coding tasks involve fewer truly parallelizable tasks than research". They also report an early failure mode of spawning 50 subagents for simple queries. A 15× multiplier applied to a task that did not need it is just a 15× bill.
Anthropic reports an early failure mode of its own system: agents "spawning 50 subagents for simple queries". A 15× multiplier applied to a task that never needed parallelism is not an architecture — it is a 15× bill with extra latency attached. Scale the effort to the task: one agent for fact-finding, a handful for genuine comparisons, ten or more only for real research.
| Product | Plan | What's metered |
|---|---|---|
| Claude Code | Included in Pro ($20/mo), Max (from $100/mo), Team ($20–100/seat) | Rolling 5-hour and weekly limits. Past the limit, usage credits bill at standard API rates |
| GitHub Copilot | Free · Pro $10 · Pro+ $39 · Max $100 · Business $19 · Enterprise $39 | AI credits at $0.01 each; completions unmetered on paid plans |
| Cursor | Hobby free · Pro $20/mo · Teams $40/user | Included allowance, then on-demand usage billed in arrears |
| OpenAI Codex | Via ChatGPT Plus $20 / Pro $100 / Pro $200 | Repriced from per-message to per-token credits in April 2026 |
| Amp (Sourcegraph) | No subscription; $5 minimum credit purchase | Zero markup — pure pass-through of provider API pricing |
| OpenHands | MIT-licensed, free to self-host | Bring your own key, or their provider at cost with no markup |
Two structural notes. Amp and OpenHands are the only two here that charge you nothing on top of the model — everything else bundles a margin somewhere. And Copilot Max is the outlier in the other direction: $100/month reportedly buys $200 in AI credits, a subsidy nobody else offers.
Anthropic's own averages give you the break-even directly. At $13 per active day, a $200/month subscription pays for itself at roughly 15 active days — which is most working months. At $150–250/month typical spend, a $100 or $200 plan is straightforwardly cheaper than the API for the median developer.
Because the vendor captures the caching upside. Claude Code reuses a large stable prefix across turns, so most of its input is billed at the 0.1× cache-read rate rather than full price. A naive API integration that does not cache properly pays the full rate and loses that advantage entirely.
You cannot use a subscription programmatically. Anthropic blocks API access on Pro and Max plans, and has shut down third-party bridges. So if the agent needs to run in CI, in a backend service, or inside your own product, the subscription is not an option and you are on API rates — where all the levers below become mandatory rather than optional.
| Control | Documented effect | Source |
|---|---|---|
| Context editing (auto-clear stale tool results) | −84% tokens on a 100-turn evaluation, and +29% task performance | Anthropic, September 2025 |
| Memory tool + context editing together | +39% over baseline performance | Anthropic |
| Prompt caching in the loop | Stable prefix billed at 0.1× instead of 1× — effectively 90% off the largest line in the bill | Anthropic pricing docs |
| Preprocessing tool output before it enters context | Log output "from tens of thousands of tokens to hundreds" | Anthropic Claude Code docs |
| Cheaper model for coordination and simple subagents | Opus is 5× Haiku; one measured study found GPT-5 used 1.5M fewer tokens than Sonnet 4.5 on identical tasks | Vendor pricing; SWE-bench trajectory analysis |
| Capping the thinking budget | Default budget is "tens of thousands of tokens per request", all billed as output | Anthropic docs |
| Clearing the session between unrelated tasks | Anthropic names uncleared long sessions as one of the top two causes of surprise bills | Anthropic docs |
| Batch API for offline agent work | −50% on input and output | Anthropic pricing docs |
Anthropic names them explicitly, and they are both free to fix: long sessions that were never cleared, and Opus left as the default model. Neither requires an architecture change. Both are habits.
Several of these controls are easier from a gateway than from the vendor API directly: per-key spend caps, per-team attribution, and the ability to route a coordination step to a cheap model without touching your code. Our gateway guide covers what that costs, and our comparison page lists the current landed prices.
Here is a realistic agent task priced out, using current Claude list rates. One feature implementation: 100 API calls, 2,000,000 cumulative input tokens at a 75% cache hit rate, 40,000 output tokens.
| Model | One bug fix | One feature | 20 features/month |
|---|---|---|---|
| Gemini 3.1 Pro | $0.38 | $1.60 | $32 |
| Claude Sonnet 4.6 | $0.54 | $2.28 | $46 |
| Claude Opus 4.8 | $0.90 | $3.80 | $76 |
| GPT-5.5 | $0.95 | $4.00 | $80 |
| Claude Fable 5 | $1.80 | $7.60 | $152 |
Now the single most important line in this article. The same Sonnet 4.6 bug fix costs $0.54 with caching and $1.35 without — a 2.5× difference from one configuration flag. Before you switch models, switch on the cache.
Budgeting for agents is harder than budgeting for APIs because the same task does not cost the same twice. The SWE-bench trajectory analysis found runs on the same task differing by up to 30× in total tokens, and the most expensive problem in the set cost about 7M more tokens on average than the cheapest.
Worse, the models cannot predict their own cost. The best correlation between a model's predicted and actual token usage was 0.32 — and some models spent more than twice the task's own cost merely trying to estimate it.
The practical consequence: do not budget on an average. Budget on a cap. Set spend limits per workspace, per key and per team, because the tail of this distribution is where the $15,000 months live. Our Claude pricing breakdown covers where those caps live and what happens when you hit them.
Anthropic's published figures for Claude Code: about $13 per developer per active day, $150–250 per developer per month, with 90% of users staying under $30 on any active day. Power users on heavy automation reach $500–2,000 per month.
Because an agent re-sends its entire accumulated context on every turn. One analysis of SWE-bench trajectories found agentic coding uses roughly 3,500× the tokens of a single-round code question and 1,200× a coding chat.
Input, by a wide margin. Cache reads dominate both token volume and dollar cost in real agent trajectories — the accumulated context is so large that cheap-per-token reads outweigh expensive-per-token output in aggregate.
Cached input is billed at 0.1× the normal rate, a 90% discount. In published token math, the same bug fix costs $0.54 with caching and $1.35 without — a 2.5× difference from one flag.
Substantially. Anthropic measured multi-agent systems at about 15× the tokens of a chat interaction, and its own agent teams at about 7× a standard session, because each teammate maintains its own context window.
For the median developer, yes. At Anthropic's own average of $13 per active day, a $200/month plan breaks even at roughly 15 active days. But subscriptions cannot be used programmatically — if the agent runs in CI or inside your product, you are on API rates.
Anthropic names two causes above all others: long sessions that were never cleared, and the flagship model left as the default. Both are free to fix.
Yes, and it has been documented. A Cursor user measured one call with ~4,000 tokens of actual input and ~21,000,000 cache-read tokens, billed at about $12 — the tool was replaying a large hidden prompt state on every call.
Poorly. Runs on the same task have been measured differing by up to 30× in total tokens, and models predict their own usage badly — the best correlation observed was 0.32. Budget on a spend cap, not an average.
Not beyond a point. The trajectory analysis found accuracy peaks at intermediate cost and declines after it, with higher output-token usage correlating with lower task accuracy. Expensive runs are often failing runs.
Prompt caching, then context management. Anthropic measured context editing cutting token consumption by 84% on a 100-turn evaluation while also improving task performance by 29%.
On published token math for a typical feature task, Gemini 3.1 Pro at about $32 for 20 features per month, against $76 on Claude Opus 4.8 and $80 on GPT-5.5. But token efficiency matters as much as price — see our real-cost comparison.
Amp and OpenHands pass provider pricing through with zero markup, so you pay only the model. Everything else bundles a margin somewhere. If your spend is large, that margin is worth measuring.
Set workspace spend limits in the provider console, per-key limits where your gateway supports them, and a maximum turn count in the agent itself. The tier spend cap is a hard stop, and a runaway agent will find it.
An AI agent's bill is not driven by what it writes. It is driven by what it re-reads, over and over, on every turn of a loop that grows quadratically. That single fact explains the $13-a-day average, the $15,000 month, and the $12 single call.
The fixes, in order of return: turn on prompt caching, because input is the bill and caching cuts it 90%. Manage the context — Anthropic measured 84% fewer tokens and better results. Stop defaulting to the flagship, because most agent turns are glue, not reasoning. And cap the spend, because the same task can cost thirty times more on a bad day and neither you nor the model can predict which day that is.
Do those four and an agent is an ordinary line item. Skip them and it is a budget incident with a story attached.
Copyright © 2026 Best AI Gateways
Independent ranking. We may be rewarded for recommending the service we rate best and sending users to it — that reward pays for the research behind this comparison and never buys a ranking position, at no extra cost to you. Information is provided “as is” without warranty. See our Disclaimer & Terms.