What an AI agent costs to run, and when it pays back

An AI agent costs the number of model calls it makes, times the tokens in each call, times your provider's price per token, plus retries and tool calls. Because an agent reads its whole growing history again on every step, each step costs more than the one before, and the agent pays for itself only when the value of the tasks it completes correctly is larger than that spend plus the human time needed to check its work.

If you came looking for an AI inference cost calculator, the model below shows the part a spreadsheet usually misses: how the bill grows when agents keep going.

Try it: a four-agent loop with and without a budget

Runaway agent loop, a public model by Machinations. Two identical rings of four agents pass a task around for 40 steps. Loop 1 has no spending limit. Loop 2 stops when its budget cannot cover the next step.

In this model the first step costs about $0.10 and every later step costs about $0.10 more than the one before, with up to 30% random variation for prompt length. The figures below come from single Plays on 19 November 2026. Yours will differ slightly.

The model starts to Play by itself when it comes into view. The button under its chart Plays it again; in this model that button is named Experiment.

  1. Watch the first Play. Loop 2 starts with a budget of $20. Loop 1, with no limit, spends about $80 to $86 over 40 steps. In our Play, Loop 2 paid for 18 steps, spent $18.71 and stopped at step 19.
  2. Press Play two or three more times. The cost of each step varies, so the totals move a little. Watch which step Loop 2 stops on, and how far Loop 1 has run past it by the end.

The page plays the model with the $20 budget it was saved with. To try a larger one, Remix the model into your own account and change the amount in Loop 2 Budget Vault. We did that twice:

  • A budget of $40. In our Play, Loop 2 paid for 28 steps and spent $40.42 before stopping at step 29. Twice the budget bought 10 more steps, not 18.
  • A budget of $80. By the arithmetic of the model, all 40 steps cost about $82, so even four times the first budget only just reaches the end.

Why each step costs more than the last

A language model has no memory between calls. For the agent to remember what it has done, each call sends the conversation so far: the instructions, earlier steps, tool results and files it has read. Providers charge per token for that input every time it is sent, and usually charge a higher rate for the output.

So step 30 of a task carries the weight of the 29 steps before it. If each step adds a similar amount of context, the cost per step rises in a straight line and the total rises with the square of the number of steps. In the model, 40 steps at a flat $0.10 would cost $4. With the growing context they cost about $82.

What goes into the cost of one task

  • Calls per task. An agent that plans, acts, checks and retries can make dozens of calls where a chatbot makes one.
  • Tokens per call. Input grows with the context. Tool results and whole files are often the largest part.
  • Price per token. It differs by model, sometimes by a wide margin. Take it from your provider's current price page.
  • Retries and failures. A failed task still costs what it used. Several agents passing work between them multiply the calls.
  • People. Someone reviews the output, fixes mistakes and maintains the prompts and tools.

When an agent pays for itself

Work it out per task. The value of an attempt is the value of a finished task times the share of attempts that succeed. The cost of an attempt is the model spend plus the human review time. The difference is your margin per task, and the fixed cost of building the agent divided by that margin is the number of tasks to break even.

Here is an illustration with invented round numbers. A task takes a person 10 minutes, which at $40 an hour is worth $6.67. The agent succeeds 80% of the time, so an attempt is worth $5.33. Each attempt costs $0.40 in tokens and 2 minutes of review, $1.33, for a total of $1.73. The margin is $3.60 per attempt. If the agent cost $9,000 to build, it breaks even after 2,500 tasks.

The result is most sensitive to the success rate and the review time, not the token price. At a 50% success rate the same agent earns $1.60 per attempt and needs 5,625 tasks.

How to keep the cost flat

Set a spending limit per task, as Loop 2 does, so a stuck agent stops instead of looping. Cap the number of steps. Summarise or drop old context so later steps do not carry everything. Use cached input pricing where your provider offers it, since repeated context is the bulk of the bill. Send simple steps to a smaller model, and measure the cost per completed task, not per call.

Frequently asked questions

How do you estimate the cost of an AI agent?

Estimate the number of model calls per task, the input and output tokens in each call, and multiply by your provider's price per token. Add retries, tool costs and the human time spent reviewing. Remember that input tokens grow with every step, because the agent sends its history again.

Why do AI agents cost more than chatbots?

A chatbot answer is one call. An agent makes many calls for one task and sends its growing context with each one, so the tokens billed for a task can be many times the tokens in the final answer.

What is a runaway agent loop?

It is an agent, or several agents handing work to each other, that keeps taking steps without finishing. Each step costs more than the one before, so the bill grows quickly. A spending limit or a step limit per task stops it.

How do I work out when an AI agent pays for itself?

Take the value of a completed task times the success rate, subtract the token cost and the human review cost per attempt, and divide your fixed build cost by that margin. The answer is the number of tasks to break even.

Does a cheaper model always lower the cost?

Not always. A smaller model costs less per token, but if it fails more often the retries and the extra review can cost more than the saving. Compare models on cost per completed task.

Share this article

More articles

Browse all articles

Draw the stocks, flows and loops yourself

Turn the ideas in this article into a model you can Play, then change one assumption and watch the behaviour shift.