ArrayKit

Agent Loop Cost Estimator

Cost an agent loop turn by turn, with the history it re-sends and the caching it gets.

Agent Loop Cost Estimator

Cost an agent loop turn by turn, with the history it re-sends and the caching it gets.

Only sizes and rates are entered here, never prompts or results. Nothing is uploaded.

Find out why your cache is missing

About Agent Loop Cost Estimator

An agent loop does not cost one call multiplied by the number of turns, and the difference is not small. The API is stateless, so every turn re-sends everything before it — the system prompt, the tool definitions, and every message and tool result so far. Turn eight sends everything turns one through seven sent, plus what they produced. That makes the cost grow with the square of the conversation rather than with its length, which is why loops that seem cheap in testing are not. This walks the loop turn by turn, applies caching where caching applies, and says which turn overflows the window.

Features

  • Every turn priced separately, with the history it re-sends
  • Caching applied to the fixed prefix only, which is the honest model
  • The same loop priced without caching, for comparison
  • Counts the tokens re-sent purely because the API is stateless
  • Says which turn overflows the context window
  • Batch pricing as a toggle
  • A per-turn bar chart, so the growth is visible
  • Rates carrying the date they were checked

How to use the Agent Loop Cost Estimator

  1. Pick a model and how many turns you expect
  2. Enter the fixed prefix, the output and the tool result sizes
  3. Set a realistic cache hit rate
  4. Read the total, the saving, and where it overflows

Example

Input

8 turns, 4K prefix, 1.5K tool results

Output

Turn 8 sends 19.4K tokens — turn 1 sent 4.5K

The growth is the history, not the work.

Common errors & troubleshooting

  • My real bill is higher than this. — Tool results are usually the culprit — they are the largest and least predictable input. Try the size of your worst tool result rather than a typical one.
  • The cache saving looks too good. — Only the fixed prefix is treated as cacheable, which is already the conservative assumption. If your prefix changes between turns, set the hit rate lower.
  • It says the window overflows. — The conversation outgrows the model before the loop finishes. Compaction, context editing, or smaller tool results are the fixes, in that order of effect.
  • How do I know my token sizes? — Measure one real turn with the token counter and use those figures. The shape of the answer matters more than the precision.

Frequently asked questions

Why does an agent loop cost more than the same work in one call?
Because the whole conversation is re-sent every turn. Ten turns is not ten calls' worth of input — it is the sum of a growing conversation, which is why the cost curve bends upward.
What drives the cost most?
Tool result size, usually by a distance. Output tokens are priced higher per token but there are far fewer of them; a verbose tool that returns a page of JSON each turn is what turns a cheap loop into an expensive one.
Is the cache hit rate realistic at 90%?
For a stable system prompt and a fixed tool list, yes. If your prefix contains anything per-request, it is closer to zero — the cache planner is the tool for finding out which you have.
Should I use batch pricing?
Only if the work is not interactive. It halves the bill and gives up the ability to react, which suits evaluation runs and bulk processing rather than an agent someone is waiting on.
How accurate is this?
It is a model, not a quote. It gets the shape right — the growth, the cache effect, the overflow point — from figures you supply. Published rates change, so the date they were checked is shown next to them.

Related tools

  • Prompt Cache Planner — Order the blocks of a request so the cacheable prefix is as long as possible.
  • Context Window Planner — Budget a context window across prompt, tools, history and the reply.
  • Batch Request Builder — Turn a table of rows into a batch job, with unique ids per request.
  • LLM API Cost Calculator — Estimate GPT, Claude and Gemini API costs from token counts, with custom price overrides.
  • SSE Stream Viewer — Paste a raw streaming response and get the text, tool calls and usage back.
  • Token Counter — Count tokens for GPT, Claude and Gemini live — exact OpenAI counts plus Claude/Gemini estimates.

More AI & Agents tools

See all AI & Agents tools · All tools