AI Agent Costs: Why Agents Burn Tokens and How to Contain It
AI agent cost grows with every step, because each tool call re-sends context. Learn why agents burn tokens and how to cap steps, tokens and spend.
Updated
AI agent cost is the total of every model call an agent makes to finish one task. An agent makes many calls per task, and each call re-sends the context built up so far, so the bill grows faster than the step count.
Why are AI agents so expensive?
A chat reply is one call. An agent run is a loop. The model reads the task, picks a tool, gets the result, and calls the model again. The model keeps no memory between calls, so every pass sends the full history again: the system prompt, the tool definitions, earlier messages and every tool result so far. The provider bills all of it on every call.
That makes input tokens the hidden cost. Take a hypothetical agent with a 4,000-token system prompt and tool list. Each step adds 2,000 tokens of tool output. Over 10 steps, the model reads 130,000 input tokens in total, while the context only grows to about 24,000 tokens by the end of the run. At the Claude Opus list price of $4 per million input tokens, the input side of that run is $0.52. On Claude Haiku at $0.10 per million input tokens, it is about $0.013. These figures are hypothetical and use round numbers.
What does a tool call add to the bill?
Tool calls add cost in three places. First, the tool list is sent on every step, so a long list is paid for on each call, even when the agent uses only one or two of the tools. Second, tool results stay in the context. A database dump or a full web page can add thousands of tokens that the model reads again on every later step. Third, the model’s tool-call arguments and any reasoning count as output tokens, and output is billed at a higher rate than input. At Claude list price, that is $20 per million output tokens on Opus, against $4 per million for input.
How much does an AI agent cost to run?
Start with one model in the loop. Multiply calls per task by the average input tokens per call, then by the input price. Add the output tokens at the output price. Then multiply the result by tasks per month.
Using the hypothetical run above, and assuming the agent writes 500 output tokens per step, one run costs about $0.62 on Claude Opus: $0.52 for input and $0.10 for output. At 1,000 tasks a month, that is about $620 a month, still hypothetical. Budget for the long runs, not the typical one. A run where the agent retries or wanders can cost several times a normal one, and those runs set the monthly total. For OpenAI, Google or any other vendor, check the current pricing page before you use their rate.
How do I reduce AI agent costs?
Bound the loop first, then shrink what each step sends.
- Cap steps per run. Stop the loop at a fixed number of model calls, then return what the agent has or hand the task to a person.
- Cap tokens per run. Count input and output tokens as the run goes, and stop when it passes its budget.
- Trim tool results before they enter the context. Have the tool return the fields the model needs, not the whole payload. For more ways to shorten prompts and outputs without losing quality, see /guides/cut-tokens-per-call/.
- Send only the tools a step needs. A shorter list costs less on every call.
- Cache the stable prefix. The system prompt and tool list stay the same from step to step, so caching can cover them. See /guides/prompt-caching-savings/ for what caching saves and when it does not help.
- Route the easy steps to a smaller model and keep the hard ones on the larger model. See /guides/llm-model-routing/ for how to split traffic by step.
What causes a runaway AI agent?
A runaway run is a loop with no exit. The usual causes are a tool that keeps failing and gets retried, two tools that send the agent back and forth, and a goal the agent cannot reach but keeps trying. Each one can run until someone notices the bill.
Fix it in code, not in the prompt. Put a hard step limit and a timeout around every run. Stop the run when the same tool error repeats, since the next retry usually fails the same way. Then set a spend limit on the API key at the provider. Decide in advance what the product does when that limit trips: queue the task, switch to a cheaper path, or fail with a clear message.
Should you fine-tune the model behind an agent?
Fine-tuning fits one step that repeats many times, such as picking the right tool from a fixed list or filling the same arguments in the same format. It does not fit an agent that plans open-ended work across many unknown tools. For that step-level work, see /guides/fine-tuning-for-tool-calling/ before deciding.
Own Weights fine-tunes an open-weight model for one high-volume task, tests it against the current model on your own data, and serves it in your cloud account or on-prem. The customer owns the weights. On our public exam, 510 commercial contracts with answers marked by lawyers, each document was scored by a model that never saw it in training. Our Accuracy model scored 0.717 (the share of exactly-right quotes, where 1.0 is perfect). Claude Opus scored 0.635 and Claude Haiku scored 0.584, so on that exam the trained model beat both. Claude took that exam with one prompt and no task training, while our models were fine-tuned for it. This shows what training for one task does. It is not a legal product or legal advice, and it does not mean our model beats Claude at everything. A trained model can beat a frontier model on a narrow task with good data, but that is not a guarantee for your task.
Fine-tuning is the wrong choice for a low-volume agent. Low volume may not pay for training and serving a model of your own, and a frontier model is simpler to run. Check the numbers at your own volume before you decide.
Start with the free AI cost audit. It lists your AI calls, the models they use and their estimated cost, and flags calls inside loops and calls with no timeout, so you can see which agent costs the most before you set any limits. If you want us to look at a specific agent, ask for a call.
Questions
ai agent cost
AI agent cost is the sum of tokens across every model call in one task, plus any tool charges. Multiply calls per task by tokens per call and by the price per token, then by tasks per month. Take the rates from your provider's current pricing page.
why are ai agents so expensive
Each step in an agent loop sends the whole history again, so input tokens climb with every step. Tool definitions and tool results add to that on every call, which makes a ten-step run cost far more than its first step.
how much does an ai agent cost to run
There is no single figure. Work it out from steps per run, average tokens per step, the price per token and runs per month, then add output tokens at the output price. Your provider's pricing page has the rates to use.
tool calling token cost
A tool call costs the tool list sent with the request and the result the model has to read afterward. Keep the list to the tools a step needs, and return only the fields the model uses.
runaway ai agent cost
A runaway run is an agent loop with no exit, such as a tool that fails and gets retried forever. Stop it with a step limit, a token budget and a timeout in code, plus a spend limit on the API key.