How much does it cost to run an AI agent? A real invoice, broken down

The short version

  • Anthropic's own published figures for Claude Code: ~$13 per developer per active day, $150–250 per developer per month, with 90% of users under $30 on any given day. Power users on heavy automation reach $500–2,000/month.
  • A peer-reviewed-style analysis of SWE-bench trajectories found agentic coding consumes roughly 3,500× more tokens than a single-round code question. The same task, re-run, can differ by up to 30× in tokens.
  • Input dominates, not output. Cache reads are the largest line in a real agent bill — the accumulated context is so large that cheap-per-token reads outweigh expensive-per-token output.
  • Anthropic measured multi-agent systems at ~15× the tokens of a chat interaction, and its own agent teams at ~7× a standard session. Parallelism is not free.
  • Context editing cut token consumption 84% on a 100-turn evaluation in Anthropic's own testing — the single largest documented lever.

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.

Why an agent costs 1,000× a chat message

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.

Input dominates, and this surprises everyone

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.

Where the money goes in an agent run Input dominates the bill Cache reads (accumulated context) Fresh input Output + thinking Illustrative shape of a trajectory. Cache reads outweigh output despite being ~80x cheaper per token.
Output tokens cost roughly 80× more each — and still lose. The accumulated context is simply that large.

More tokens does not mean better results

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 anatomy of one agent turn

What you re-send on every turn The prefix is constant. The history is not. Turn 5 pays for everything turns 1–4 read. Turn 1 system tools query ≈ 6k tokens Turn 2 system tools query file read (18k) ≈ 24k tokens Turn 3 system tools query file read test output (22k) ≈ 46k tokens Turn 4 system tools query file read test output thinking ≈ 60k Four turns. One question. Roughly 136,000 input tokens billed — because turn 4 pays for turns 1, 2 and 3 again. Uncached on Opus 4.8 ($5/1M): $0.68  •  Cached at 0.1×: $0.07  •  Same work, 10× the bill.
Every turn re-sends everything before it. This is why caching is not an optimisation for agents — it is a prerequisite.

What accumulates

  • Tool definitions — billed as input on every call, whether used or not.
  • Tool results — file contents, test output, stack traces, screenshots. They never leave the context on their own.
  • Thinking tokens — billed as output when generated, then billed as input when read back from cache on later turns.
  • Retries — a failed tool call is a paid tool call.

Which actions cause the spikes

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.

What teams actually pay

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.

Published agent spend figures — July 2026
SourceFigureContext
Anthropic (own docs)~$13 per developer per active dayAverage across Claude Code users
Anthropic (own docs)$150–250 per developer per monthTypical monthly cost
Anthropic (own docs)90% of users under $30 on any active dayThe distribution is heavily skewed
Anthropic (own docs)$500–2,000/monthPower users running heavy automation
Microsoft (reported)~$2,000 per engineer per monthLed to moving engineers to a $39/seat flat-rate tool
Uber (reported)2026 AI budget exhausted in 4 monthsSame category of spend
Developer self-reports (Hacker News)$40/day · $250 in 3 weeks · $15,000 in one monthAnecdotal, 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.

Documented blow-ups

The interesting failures are not "we used it a lot". They are cases where the bill decoupled from the work.

What developers report spending

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 Cursor case: $12 for one call

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:

One agent call, as measured by the user
ComponentTokens
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."

The multi-agent multiplier

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.

Token multipliers, measured by Anthropic Chat interaction Single agent~4× Agent teams~7× Multi-agent system~15×
Anthropic’s own numbers. Parallel agents are a cost decision before they are an architecture decision.

When is it worth it?

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.

Subagent sprawl is the failure mode to watch

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.

What the agent products cost

Agent product pricing — July 2026. Verify at source before committing budget
ProductPlanWhat's metered
Claude CodeIncluded 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 CopilotFree · Pro $10 · Pro+ $39 · Max $100 · Business $19 · Enterprise $39AI credits at $0.01 each; completions unmetered on paid plans
CursorHobby free · Pro $20/mo · Teams $40/userIncluded allowance, then on-demand usage billed in arrears
OpenAI CodexVia ChatGPT Plus $20 / Pro $100 / Pro $200Repriced from per-message to per-token credits in April 2026
Amp (Sourcegraph)No subscription; $5 minimum credit purchaseZero markup — pure pass-through of provider API pricing
OpenHandsMIT-licensed, free to self-hostBring 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.

Subscription or API?

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.

Why subscriptions win for heavy users

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.

The catch that decides it for many teams

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.

Controls that actually work, with published effect sizes

Agent cost controls, ranked by documented effect
ControlDocumented effectSource
Context editing (auto-clear stale tool results)−84% tokens on a 100-turn evaluation, and +29% task performanceAnthropic, September 2025
Memory tool + context editing together+39% over baseline performanceAnthropic
Prompt caching in the loopStable prefix billed at 0.1× instead of 1× — effectively 90% off the largest line in the billAnthropic pricing docs
Preprocessing tool output before it enters contextLog output "from tens of thousands of tokens to hundreds"Anthropic Claude Code docs
Cheaper model for coordination and simple subagentsOpus is 5× Haiku; one measured study found GPT-5 used 1.5M fewer tokens than Sonnet 4.5 on identical tasksVendor pricing; SWE-bench trajectory analysis
Capping the thinking budgetDefault budget is "tens of thousands of tokens per request", all billed as outputAnthropic docs
Clearing the session between unrelated tasksAnthropic names uncleared long sessions as one of the top two causes of surprise billsAnthropic docs
Batch API for offline agent work−50% on input and outputAnthropic pricing docs

The top two causes of surprise bills

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.

Where a gateway helps

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.

A worked invoice

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.

Same task, different models — published token math at current list prices
ModelOne bug fixOne feature20 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.

The variance problem nobody prices in

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.

Common mistakes

  • Running an agent without caching. Input is the bill, and caching cuts it 90%. Everything else is a rounding error next to this.
  • Optimising output length. You are paying for accumulated input, not for what the model says.
  • Leaving the flagship as default. Opus is 5× Haiku, and most agent turns are tool-calling glue, not reasoning.
  • Never clearing the session. A three-hour session pays for its first hour on every call of its third.
  • Reaching for multi-agent too early. 15× the tokens, and coding is explicitly a poor fit per Anthropic's own research.
  • Budgeting on the average. The same task can cost 30× more on a bad run. Cap it.
  • Dumping raw tool output into context. Grep the log before the model sees it — tens of thousands of tokens become hundreds.

FAQ

How much does it cost to run an AI coding agent?

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.

Why are AI agents so much more expensive than chat?

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.

Is input or output the bigger cost in an agent?

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.

How much does prompt caching save on an agent?

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.

Do multi-agent systems cost more?

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.

Is a subscription cheaper than the API?

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.

What causes surprise agent bills?

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.

Can an agent cost $12 for a single call?

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.

How predictable are agent costs?

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.

Does spending more tokens produce better results?

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.

What is the single biggest lever on agent cost?

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%.

Which model is cheapest to run an agent on?

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.

Should I self-host or use a hosted agent?

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.

How do I cap agent spend?

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.

The bottom line

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.

Sources

  • Anthropic — "Manage costs effectively", Claude Code documentation. Retrieved 14 July 2026. Per-developer spend figures, agent-team multiplier, top causes of surprise bills.
  • Anthropic — "How we built our multi-agent research system", June 2025. The 4× and 15× token multipliers, 90.2% performance uplift, 80% variance explained by token usage.
  • Anthropic — "Managing context on the Claude Developer Platform", September 2025. Context editing: 84% token reduction, +29% and +39% performance.
  • Anthropic — Claude Platform pricing documentation. Retrieved 14 July 2026. Cache multipliers, batch discount, model prices.
  • "How Do AI Agents Spend Your Money? Analyzing and Predicting Token Consumption in Agentic Coding Tasks" — preprint analysing trajectories from eight frontier models on SWE-bench Verified, 2026. Token multipliers, cache-read dominance, 30× variance, self-prediction correlation.
  • Hacker News — "Cancelled 2x Cursor Ultra plans, here's why", January 2026. The 21M cache-read token call.
  • Hacker News — "Ask HN: How much are you spending on AI coding tools at work?", March 2026. Self-reported spend figures.
  • Vendor pricing pages for Claude, GitHub Copilot, Cursor, OpenAI Codex, Amp and OpenHands. Retrieved 14 July 2026.
  • Published cost-per-task token math across models, July 2026.

About this article. Written by the Best AI Gateways research team. Vendor figures come from Anthropic's own documentation and engineering blog. Developer spend figures from Hacker News are self-reported and unaudited — we quote them as quotes, not as data. Where a widely-circulated incident could not be traced to a primary source, we left it out.

Published 14 July 2026. Last updated 14 July 2026. 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. Model names and trademarks belong to their respective owners. Pricing is set by each provider and can change — always verify before you build.

Best AI Gateways

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.