How Much Does It Cost to Run an AI Agent?
· 15 min read
The short answer: no single price, four levers
So how much does it cost to run an AI agent? There is no single price: the cost depends on the model you pick, how large the context grows, how many tool calls the agent makes and how long it runs. In its June 2025 write-up of its multi-agent research system, Anthropic reports that agents use several times more tokens than chat, and multi-agent systems many times more. Those observations predate current models, but they warn that an estimate built from chat usage will underestimate an agent's bill. The number that answers the question for you is your cost per accepted task: each kind of token times its rate, plus fees that are not tokens, divided by the tasks you kept. The last section shows how to measure it.
Two ways of paying need to stay apart. A subscription bills a plan with its own usage limits rather than per token, though some plans let you pay for extra usage past the limit; check your plan's terms before running agents on it. The API bills per token, so every resent message, tool result and retry is paid for. A local model is a third route: a cost to weigh against your measured API bill, not a shopping list. Below: why an agent's bill is higher and more erratic than chat, why more spend does not always buy better results, and how to measure your own. Most mechanisms come from Anthropic's Claude Code and Claude API documentation, which describes them in detail, reread on 2026-11-23. Other providers have similar mechanisms, such as OpenAI's prompt caching covered below, but the exact rules differ: check your own provider's documentation.
Why an agent costs more than a chat
A chat is one round trip; an agent is a loop. According to Claude Code's cost documentation, Claude Code sends the full conversation with every request, and each tool use sends another request carrying the results. Read a file, run the tests, read the error, edit, run again: every step resends everything before it.
Picture each step adding one block of similar size. Step one sends one block, step two sends two, step ten sends ten: over ten steps the agent has sent fifty-five blocks, not ten.
Prompt caching softens this without removing it: the history is re-read at the cached rate, but it is still re-read. That is why a one-line question in a session left open all day still draws usage for the whole conversation.
Tools add weight. The Claude API pricing documentation counts as billable input the tool names, descriptions and schemas, the tool_use and tool_result blocks, and a tool-use system prompt added automatically when tools are provided. Web search results count as input in the turn and in later turns. Web fetch costs nothing beyond the fetched tokens, which max_content_tokens can cap.
Errors compound too. Anthropic's June 2025 write-up notes that agents are stateful, that errors compound, and that restarting from the beginning after one is expensive. A restart repeats a long, paid trajectory.
What the bill is made of, line by line
Input is everything sent on a request: system prompt, tool definitions, conversation so far, latest tool results. Output is what the model writes back, tool calls included. Thinking tokens are billed as output, so a model that reasons at length costs more on that line even when the visible answer is short.
Cached input splits into cache writes, when a prefix is stored, and cache reads, when a later request reuses it at a reduced rate. On the OpenAI side, prompt caching is on by default for supported models: reused tokens are billed at a reduced cached-input rate, reported in usage.input_tokens_details.cached_tokens, and recent models offer extended retention.
Some lines are not tokens. Server-side tools such as web search are charged per use. Code execution on the Claude API is free alongside recent web search or web fetch versions, otherwise billed by container time beyond a monthly free allowance. Claude Managed Agents also bill session runtime, which accrues only while the session is running, with no Batch discount.
One newer trap: Anthropic states that recent Claude models use a tokenizer that produces noticeably more tokens for the same text than earlier ones. A per-token rate does not compare across model generations until you count tokens on the target model.
The table below gives list rates as read on 2026-11-23 (see the table's sources).
| Offer | Condition | Input (USD per 1M tokens) | Output (USD per 1M tokens) | Prompt caching (USD per 1M tokens) | Sources |
|---|---|---|---|---|---|
| Claude Sonnet 5.5 | Standard API rate | $2.00 | $10.00 | Read $0.10, write $2.50 | [1] |
| Claude Haiku 5.5 | Prompts up to 100K tokens | $0.10 | $0.50 | Read $0.01, write $0.125 | [1] |
| Claude Haiku 5.5 | Prompts over 100K tokens | $0.50 | $2.50 | Read $0.05, write $0.625 | [1] |
| Gemini 4 Argon, Standard | Through 2026-11-30 | $2.00 | $10.00 | $0.10 (implicit caching only) | [2] |
| Gemini 4 Argon, Standard | Starting 2026-12-01 (announced) | $4.00 | $20.00 | $0.20 (implicit caching only) | [2] |
| Gemini 4 Argon, Batch | Through 2026-11-30 | $1.00 | $5.00 | $0.05 (implicit caching only) | [2] |
| Gemini 4 Argon, Batch | Starting 2026-12-01 (announced) | $2.00 | $10.00 | $0.10 (implicit caching only) | [2] |
| Qwen3-32B on DeepInfra | Base tier, served at fp8 | $0.08 | $0.28 | Not listed | [3] |
These are list rates in US dollars per million tokens, as the providers display them. They do not tell you what a task costs: that depends on how many input, output and cached tokens each accepted task uses, so estimate it from measured token usage on your own tasks.
A lower rate is not an equivalent answer. These offers are different models, and none of these rates establishes that one model's output matches another's quality on your tasks.
Anthropic states that its prompt caching prices reflect a 5-minute TTL. The rate for Claude Haiku 5.5 depends on prompt length: prompts over 100K tokens are billed at the higher row. The same page states that US-only inference is billed at 1.1x the input and output rates, and that batch processing saves 50%, without listing per-model batch rates.
Google lists the Gemini 4 Argon rates up to 2026-11-30 as valid through that date and announces higher rates starting 2026-12-01; both are shown. Its output price includes thinking tokens, and the model supports implicit caching only (explicit caching is not supported). Batch is a separate service tier, not the interactive rate.
DeepInfra serves Qwen3-32B at fp8 precision and also offers Priority and Flex tiers at other rates. A hosted open-weight model at fp8 is not the same thing as running a local quantization of it.
Listed rates can change between two readings, as the announced Gemini 4 Argon rates show. This table expires 30 days after its reading date; check the provider's page before applying a rate to your own usage.
Sources
- Claude pricing, API section (Sonnet 5.5, Haiku 5.5), Anthropic, read on 2026-11-23
- Gemini Developer API pricing (Gemini 4 Argon, paid tier), Google AI for Developers, read on 2026-11-23
- Qwen/Qwen3-32B model page (pricing and serving precision), DeepInfra, read on 2026-11-23
For an agent, the input and caching columns weigh more, since the whole history goes back on every request and most of it should come from the cache; output weighs more for models that think at length. A rate is not a cost per task, and a lower rate is not an equivalent answer from a different model. The table also expires, and Google has announced higher Gemini 4 Argon rates starting 2026-12-01.
Does spending more tokens buy better results?
Up to a point. On the BrowseComp evaluation, Anthropic's June 2025 write-up found that token usage by itself explained most of the performance variance, with the number of tool calls and model choice as the two other factors.
An independent study complicates that. Analysing SWE-bench Verified trajectories from frontier models, Bai, Brynjolfsson, Pentland, Pei and colleagues (posted April 2026, revised October 2026) find that runs of the same agent on the same task can differ greatly in total tokens, that accuracy often peaks at an intermediate cost and levels off, and that input, not output, drives most of the cost.
The Stanford Digital Economy Lab summary of that study (May 2026) attributes the variance partly to stochastic trajectories and to context accumulating as each step re-reads what came before. The honest reading, at least on the coding tasks that study measured: extra spend helps up to a point, then mostly stops buying accuracy.
The study adds a budgeting point: frontier models predict their own token usage poorly and systematically underestimate it, and human-rated difficulty only weakly tracks actual cost. Neither the agent's own forecast nor a human sense of difficulty reliably predicts a task's cost in advance, which argues for hard caps over estimates. A baseline measured on your own tasks beats a guess, as the last section explains.
Multi-agent setups sharpen this: Anthropic's write-up says they only make economic sense when the task's value pays for the extra performance.
The hidden lines that inflate an agent's bill
Cache expiry first. The prompt caching documentation says Anthropic's cache has a short default lifetime, refreshed free on each use and measured from the start of the request, so a long streamed response eats into the window. Step away too long and your next message misses the cache.
Invalidation is hierarchical: tools, then system, then messages. Changing tool definitions invalidates everything; toggling web search or the speed setting invalidates system and messages; changing tool_choice or adding images invalidates messages. A hit needs exactly identical segments.
Some caches never start. Below a model-specific minimum length, prompts are processed uncached with no error; the sign is that cache_creation_input_tokens and cache_read_input_tokens report neither a cache write nor a cache read.
Idle is not idle. In Claude Code, session-scoped scheduled tasks fire even while the session is idle, and cross-session messages and goal check-ins can start a new turn, each sending the full context. As of 2026-11-23, recent Claude Code versions cap idle goal check-ins per goal between your prompts (earlier versions did not), and the CLAUDE_CODE_GOAL_CHECKIN_MINUTES environment variable turns them off.
Each agent teammate runs its own context window, so usage grows roughly with team size, and a teammate keeps consuming until it exits or the session ends: a forgotten one is a running meter. Running /compact reads the whole conversation it summarizes, a large request in itself; /clear costs nothing when you no longer need the context.
Then plain neglect: the Claude Code documentation traces most unexpected spend on API or cloud plans to sessions never cleared or Opus left as the default model.
Habits and limits that bring the cost down
The same documentation names two habits as highest-impact: clear between unrelated tasks, and match the model to the job. Next, lower the effort level for simple tasks: as of 2026-11-23, thinking cannot be turned off on the newest Claude models, and it is billed as output.
Cut what the agent reads. A preprocessing hook can return only the ERROR lines of a log or the tail of test output. CLI tools such as gh, aws or gcloud add no per-tool listing, so they beat MCP servers on context, although Claude Code defers MCP definitions by default: only tool names and server instructions enter context until a tool is used.
Keep teams small and the prompts that spawn teammates focused, and put teammates on a lighter model, as Claude Code's documentation advises. Shut each teammate down when its part is done.
For non-urgent work, Batch and caching discounts combine on the Claude API, though fast mode is excluded from Batch. A longer cache lifetime costs more to write; it pays off when the agent comes back to the same context after pauses longer than the default lifetime but within the longer one. An agent that returns constantly keeps the default cache warm for free.
Then set a limit wherever your stack offers one, rather than trusting a forecast; an LLM gateway such as LiteLLM can at least track spend per key, which shows which key is running away.
When a local model is cheaper than the API
The local route trades a per-token bill for hardware you own or buy. Whether it is cheaper for you depends on volume, on the hardware you already own and on how much of the work is routine: renames, tests and boilerplate can go to a local model instead of the metered API, in exchange for hardware, power and setup time. Our breakdown of what running an LLM locally really costs does the full calculation.
Test it small before moving a whole workload. Hand one tool's routine coding steps to a local model suited to coding and compare its accepted tasks with the API bill for the same work. A team running agents all day can go further and put a private shared server behind them, turning a per-token bill into a mostly fixed cost to plan and maintain.
How to measure what your own agent costs
Pilot first. Claude Code's documentation says per-developer costs vary widely with model, codebase size and usage patterns such as multiple instances or automation, and recommends a small pilot group to set a baseline. A vendor average describes its customers, not your code.
Then use /usage. As of 2026-11-23, in recent Claude Code versions, its Session block has a prompt cache line for the main conversation: share of input served from cache, number of misses, the likely cause of the last miss (changed tool definitions, for example) and whether the cache is warm or cold; it does not cover subagents. On subscription plans, it attributes usage to skills, subagents, plugins and MCP servers, lists the heaviest /loop or scheduled tasks with per-run tokens, and recommends changes. Its figures are approximate, computed from local history on that machine only.
Know which figure to trust. The cost Claude Code displays is a local estimate at list price unless an administrator set contracted rates; the authoritative bill is the Console Cost page or your cloud provider's billing console. OpenTelemetry export streams per-user token and cost metrics into your own monitoring in near real time.
On the API, log the usage block of every request: input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens. Saved responses make this a one-liner:
jq '.usage | {input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens}' response.json
No cache reads in a long loop usually means caching was never switched on with cache_control, a prefix below the minimum length, an earlier part of the prompt (tools, system, web search or speed setting) that changes between calls, or pauses longer than the cache lifetime.
Why leaderboard costs are not a budget
Judge agents on cost and accuracy together, as the Princeton paper AI Agents That Matter (2024) argues: optimising accuracy alone leaves agents needlessly complex and costly.
The Holistic Agent Leaderboard applies that idea as a cost-aware third-party leaderboard, but as of 2026-11-23 it has paused adding new models, so its costs miss the newest ones.
Its AssistantBench page computes costs without caching and carries a known issue dated 2026-10-05: an error in nested trace accounting overstated costs for affected models, still not recalculated on 2026-11-23.
Leaderboard costs are a weak basis for a budget: to read them against what you actually spend, reuse our method for comparing independent benchmarks with real costs.
Your cost per accepted task
Finish by calculating your cost per accepted task. Across your sample, failures and retries included, price your usage at current rates: each token category, plus non-token fees such as web searches or session runtime. If part of the work runs locally, add the share of hardware, power and upkeep. Then divide the total by the tasks you kept. That number, not a list rate, tells you what your agent costs.