AI Engineeringestimator

Agent run cost estimator

An agent is a loop: the model reads the context, calls a tool, appends the result and reads everything again. Every step re-sends the whole conversation so far, so the input of step 10 is far larger than the input of step 1.

Fits the context window

Each 10-step run costs $0.235, 2.35× what it would if the context didn’t grow.

Per month$7,0501K runs a day, 30 days

The starting values are labelled examples, not measurements. Replace them with token counts from your own traces.

Context size by step

05K10K15K246810StepInput tokens

The 1M-token context window is far above this run, so it isn’t drawn.

Inputs

Sent on every step.

The request that starts the run. Also sent on every step.

Model calls in one run. Each call re-sends everything so far.

Tool results plus the model’s own reply, appended to the context after each step.

Part of the tokens added. Include reasoning tokens if the model bills them as output.

Per run$0.23510 steps
Per day$235.001,000 runs
Input per run102,500 tokensCounted on every step
Output per run3,000 tokens13% of the cost
Growth multiplier2.35×Step 10 costs $0.037, step 1 costs $0.01

Cumulative cost by step

$0.00$0.05$0.10$0.15$0.20246810StepCumulative cost (USD)
With context growthIf every step cost the same as step 1

What it shows

Each step of an agent re-sends the whole conversation so far. Later steps cost more than early ones, so a run’s cost grows faster than its length.

Pick a model, then set the prompt, the number of steps and caching. The tool shows the cost per run, per day and per month. It counts model calls only. The starting numbers are examples: use token counts from your own traces.

How to read it

  • The context chart shows input tokens rising at each step. It marks the model’s window and the first step where input plus reply no longer fit.
  • Input per run adds up the context of every step, not only the last.
  • Growth multiplier compares the run with one where every step cost the same as step 1. The dashed line on the cost chart shows that case.
  • “Whole earlier context” assumes each step reads the previous prompt from the cache. “System and tools only” caches just the fixed start. Hit rate is the share served from the cache.
  • Prices are per million tokens. A request over a model’s long-context threshold is billed at the higher rate for the whole request.

Questions

Why does agent cost grow faster than the number of steps?

Each step sends the whole context again, and the context grows by the tool results and replies of every earlier step. Input tokens across a run therefore grow with the square of the step count, while output tokens grow only in proportion to it.

How much does prompt caching save an agent?

It depends on how much of each prompt repeats. In an agent loop the earlier context is a prefix of the next prompt, so most input can be billed at the cached price when the cache hits. This tool lets you compare caching the whole earlier context with caching only the system prompt and tools.

Where do the token counts come from?

From you. Count the system prompt and tool definitions once, then average the tokens a typical step adds across a sample of real runs. The defaults are examples, not measurements.

What happens when the context passes the model’s window?

The provider rejects the request or the agent has to shorten its history by summarising, truncating or dropping tool results. The estimator marks the first step where input plus reply no longer fit, and keeps costing the later steps as if they fitted so you can see the size of the gap.

What does this estimate leave out?

Tool and infrastructure costs, retries and failed runs, cache write fees and cache expiry, batch discounts, and any variation in how many steps a run takes. Real agents also vary a lot from run to run, so measure the spread as well as the average.

Sources

Explore further

  • tokencostPython library that estimates the dollar cost of prompts and completions for many models.

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.