How it works

How AI agent costs add up

See why one task can involve several model calls, growing input, and different charges.

One task, four model calls

A research task gathers three tool results, then gets a reply.

Regular input Cache read
  1. Request 112K input tokens

    The task, background notes and instructions start the run.

  2. Request 215K input tokens

    Tool result 1 joins the earlier conversation.

  3. Request 318K input tokens

    Tool result 2 joins the earlier conversation.

  4. Request 421K input tokens

    The last tool result arrives; the model can now write its reply.

Longer bars mean more input. Tokens are small units of text.

Illustrative Gemini 3.8 Flash run, assuming successful automatic-cache reuse. Actual cache hits and billing rules vary by provider.

Open this example in the calculator →
  1. One task can take several model calls as the agent uses tools and continues.
  2. Later calls usually carry more input because earlier replies and tool results are kept.
  3. Caching can lower repeat-input charges, not remove them; each new model output is also billed.

The details, when you need them

Explore the request loop, provider-specific rules, formulas, and limits behind the estimate.

01 - Request lifecycle

One user task can become many model requests

A normal chat may stop after one response. An agent can repeatedly ask the model what to do next, execute tools, return their results, and continue until it can answer.

02 - Context growth

Each request can resend the conversation so far

The request context includes retained instructions, user messages, model outputs, tool arguments, and tool results. New content is appended as the run proceeds, so later requests are usually larger than earlier ones.

This is why total input tokens can grow faster than the number of turns. Prompt caching can reduce the price of a reused prefix, but it does not mean the reused tokens disappear from the request.

03 - Token accounting

Prompt tokens are assigned to explicit billing categories

For every simulated request, prompt context is partitioned without double counting.

Fresh input, cache read and cache write add up to the request's input context; its newly generated output is billed separately.

Fresh input

Prompt tokens billed at the ordinary input rate, including cache misses when no separate write meter exists.

Cache read

A reused prompt prefix billed at the provider's cache-hit or cache-read rate.

Cache write

New cacheable prompt tokens billed through a separate cache-creation meter when the rate card defines one.

Output + reasoning

Model-generated tokens billed at the output rate, including reasoning tokens represented by the workload assumptions.

04 - Provider cache models

Cache misses are not billed the same way by every provider

Explicit cache-write meter

A hit becomes Cache read. A new cacheable prefix can become Cache write. Claude and OpenAI models with published cache-write meters are modeled this way.

Automatic cache, no write meter

A hit becomes Cache read. A miss remains Fresh input. This covers DeepSeek, Gemini implicit caching, and the Qwen implicit-cache offerings in the calculator.

Published minimums and fixed lifetimes come from the selected rate card. Provider-managed lifetimes use the calculator's reuse-time assumption instead. Unpublished minimums are labeled as unknown; cache eligibility and real cache hits remain approximate, not guaranteed.
05 - Tool batching

Parallel tool calls share one model response

If a model emits several tool calls together, the simulator treats them as one model request and one tool batch. Their results are combined before the next model request.

Model requests per user turn

Rturn = TP +1
T tool actions P parallel actions per batch

Round up to complete tool batches, then add the final reply. Compaction requests are counted separately.

For example, four tool actions with a parallelism of two produce two tool batches plus one final-response request: three model requests for that user turn.

06 - Context compaction

Long runs can summarize and replace history

When retained context reaches the configured share of the model context window, the engine simulates a compaction request. It creates a summary, replaces older retained content, and resets or reduces the reusable cache prefix.

The compaction request itself has input and output cost. The following request then bills the compacted context according to the selected provider's cache model.

Compaction does not make an oversized request executable. If a request, including a compaction request, exceeds the configured input budget, the calculator asks you to reduce the fixed input or tool-result sizes.

07 - Calculation model

Request costs roll up to a run and then a month

1. Price each request

Crequest= k Tk× pk 1,000,000
Tk tokens in category k pk USD per 1M tokens

Add fresh input, cache read, cache write, and output including reasoning. Each request uses its applicable pricing tier.

2. Add the requests in a run

Crun= r=1R Cr

R includes every model request, including any context compaction.

3. Scale to a month

Cmonth= Crun×S×D
S runs per day D active days

Rates are normalized to price per million tokens. Catalogue presets can contain provider-specific context windows and cache rules; custom pricing uses the flat rates entered in the calculator.

08 - Assumptions and limitations

What the estimate does not claim

Generic agent approximation

Token sizes and tool cycles are representative inputs, not a replay of a proprietary agent framework.

No automatic retry model

Rate-limit waits, failed requests, exponential backoff, and retries are not added unless represented in the workload.

Single-model execution

Planning, tool use, compaction, and replies use one selected model rather than a multi-model router.

Approximate cache behavior

The engine models eligible prefix reuse deterministically; actual provider cache persistence and matching can vary.

Flat custom rates

Custom rates do not add long-context tiers, regional premiums, batch discounts, or time-based pricing bands.

Text-token API costs only

The listed rates apply to text input and generated text or reasoning, not image, audio, or video-specific meters.

Other service charges excluded

External tool APIs, hosting, grounding, and token-hour storage for explicit Gemini caches are outside this token-cost estimate.

Estimate, not an invoice

Actual usage depends on tokenizer behavior, retrieved content, model decisions, rounding rules, and current vendor pricing.

09 - Primary sources

Official pricing and cache documentation