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.
Each 10-step run costs $0.235, 2.35× what it would if the context didn’t grow.
The starting values are labelled examples, not measurements. Replace them with token counts from your own traces.
Context size by step
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.
Cumulative cost by step
The context peaks at 17,000 tokens on step 10, within Claude Sonnet 5.5’s 1M-token window.
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- estimatorLLM cost estimatorCost per request and per month across LLM APIs, with caching, batch pricing and routing.Open tool
- estimatorVector index memory plannerRAM for a vector index by type, element size and replicas, with a breakdown of vectors, links, ids and codebooks.Open tool
- calculatorRetrieval metrics calculatorGrade a ranked list and see precision, recall, hit rate, MRR, average precision and nDCG react to each move.Open tool