Back to articles

Agentic AI token consumption and cost estimation guide

Multi-step agentic workflows consume tokens very differently from single-turn calls: context accumulates across steps, tool definitions and results add tokens, and reasoning can add billed output tokens. This guide explains the patterns and provides an illustrative cost-estimation method.

Why agents cost more than single-turn queries

A single-turn LLM query sends a prompt and receives a response. An agentic loop does this repeatedly: each step sends the full accumulated conversation history, new tool results, and task instructions. Repeated calls can cost more than a comparable single-turn response, depending on call count, context reuse, and model pricing.

Three key cost drivers differentiate agentic from single-turn workloads:

  • Accumulating context window — every step re-sends prior messages, tool results, and system instructions
  • Tool-call token overhead — tool schemas, arguments, and results can add input and output tokens; measure them per workload
  • Reasoning tokens — additional billed output may vary with the model and task; account for actual usage

Agent-suitable models in the database

Of 3110 total models in the catalog, 295 support both responseSchema (structured output / tool calling) and systemMessages with valid pricing — making them suitable for agentic workflows. 189 of these also support reasoning/chain-of-thought for planning and analysis.

Total cost per million tokens ranges from $$0.060 (cheapest non-reasoning, deepseek-ocr) to $$0.190 (cheapest reasoning, gpt-oss-20b) — a 3x spread.

Compare cheapest agent models →

Agent token consumption patterns

Pattern A — Simple chain

Step 1 → Step 2 → Step 3. Context grows linearly. Total tokens = sum of (accumulated context + new instructions + output) per step. Each step re-sends the full prior conversation.

totalInput = Σ(inputTokensₙ)
totalOutput = Σ(outputTokensₙ)

Example: a three-call code-review agent sends 2,000 input tokens in step 1, 4,000 in step 2, and 6,000 in step 3, with 1,000 output tokens per call. The run uses 12,000 input and 3,000 output tokens in total. Later inputs include re-sent history, not just new instructions.

When using API usage records, add each call’s reported input and output totals once. In OpenAI usage reports, cached input is already part of input tokens, while reasoning and generated tool-call arguments are part of output tokens. Apply the relevant cached-input price rather than adding cached tokens again. Count retries, subagent calls, and separately billed hosted tools separately. Other providers may report usage differently.

Pattern B — Supervisor + workers

Planner delegates sub-tasks (fan-out, merge results). A reasoning planner decomposes the task into parallel subtasks that cheap executors handle. The merge step re-sends all worker outputs, making the final step the most expensive.

Pattern C — Loop with reflection

Agent acts, observes, reflects, retries. Context grows fastest. Each retry re-sends the entire history plus the new attempt. This pattern dominates debugging and iterative code-generation agents.

Find the expensive step

Record a run ID, step name, model and route, reported input/output tokens, cached usage, and separately billed tools or runtime for each call. Include failed calls and retries. Group the records by step to see where spend grows; a run total alone hides the costly step.

Illustrative token-only costs at an assumed $2 per million input tokens and $10 per million output tokens:

StepInputOutputCost
Plan2,000200$0.006
Research8,000300$0.019
Synthesize12,0001,200$0.036
Total22,0001,700$0.061

These are hypothetical rates, not prices for a named model. Cached-input discounts, cache writes, hosted search, sandbox time, and other tool charges are excluded. Apply each provider's actual billing units once, then add the separate tool and runtime charges before reconciling with the invoice. The actual-usage calculator helps price reported token totals.

Compare strategies for the same workflow

Suppose you run 1,000 workflows per month with 3 model calls each, for 3,000 billable calls per month. Each call uses 10,000 input and 2,000 output tokens.

Assume hypothetical rates per million tokens: $1 input and $2 output for the budget model; $3 input and $4 output for the premium model. These are not prices for named models. Hold calls and token volumes constant and vary only the model assignment.

StrategyModel at each stepMonthly cost
Budget onlyBudget → Budget → Budget$42.00
RoutedBudget → Budget → Premium$66.00
Premium onlyPremium → Premium → Premium$114.00

Under these assumptions, routing costs 42.1% less than premium-only. This is not a claim about quality or actual savings. Caching, additional reasoning tokens, retries, tool fees, and long-context price bands are excluded.

For real models, estimate calls and token volumes for each step in the calculator, then add the step costs together.

Compare cost per successful task

Token rates show what calls cost, but not what it costs to deliver an accepted result. For the same workload and measurement period, divide total billable API spend, including retries and agent steps, by the number of successfully completed tasks. Include any billed usage from failed attempts. If a timeout or error returns no usage, mark the charge as unresolved rather than assuming it is free or fully billed. Reconcile it against the provider's usage and billing records before treating the total as final.

Hypothetical example: route A attempts 100 tasks, spends $40, and produces 40 accepted results ($1.00 per successful task). Route B attempts the same 100 tasks, spends $60, and produces 80 accepted results ($0.75 per successful task). Route B costs more in total but less per accepted result in this example. These are invented numbers, not measured model-quality claims.

Use the Calculator to estimate token charges, then measure actual billable usage and outcomes using the same acceptance criteria for both routes. General benchmark scores cannot establish a workflow's success rate. Dividing cost per attempt by an assumed success rate can miss retries and additional tool charges.

Set a spend limit for each run

A monthly average cannot stop an agent caught in retries. Give each task an estimated API-and-tool cost ceiling and a separate call or iteration limit. Check the remaining budget before each new model or hosted-tool call; stop or escalate when the next call could exceed it. Include subagents and retries in the same run budget. Keep confirmed spend separate from the estimated amount reserved for outstanding calls. If a submitted call times out and its cost is unknown, retain the reservation and stop or escalate until the charge can be reconciled; the reservation is not confirmed spend. See the OpenAI spending controller example for one implementation of this approach.

For a token-only example, 20 calls averaging 6,000 input and 1,000 output tokens consume 120,000 input and 20,000 output tokens. Five similar retries raise those totals to 150,000 and 25,000. Price the combined usage with the actual-usage Calculator and add separately billed tools. This is a client-side guardrail, not a guaranteed billing cap: in-flight calls and delayed usage records can still push the final charge above the limit.

Optimization strategies

Prompt caching

Keep reusable system instructions and tool definitions at a stable prompt prefix where the provider supports caching. The catalog field cachedInputUsdPer1MTokens is a model/route-specific cached-input rate, not a universal discount. Cache-write charges, time-to-live, and storage costs vary by provider and model; check the applicable OpenAI, Anthropic, and Gemini terms.

In the illustrated web-research scenario, reusing the system prompt and tool definitions may lower repeated input charges. Actual savings depend on cache hits, write and retention fees, and the tokens reused.

Model cascade routing

Consider a lower-cost model for classification, then use a reasoning model for analysis or verification when needed. The cost difference depends on routing, output volume, retries, and task accuracy; compare the scenarios rather than assuming a fixed saving.

Context window budgeting

Shorter history is not always cheaper: rewriting a shared prompt prefix can lose cached-input discounts, and agents may re-fetch discarded tool results. Compare compaction with an unchanged-prefix baseline using billed cache-read and cache-write tokens, extra calls, and cost per successful task. A 2026 coding-agent study observed this trade-off; OpenAI's prefix guidance explains why cache reuse can fall after a rewrite.

Parallel sub-tasks

Fan out to cheap executor models and merge results with one reasoning call. This keeps context growth flat for the executor branches and concentrates cost on the merge step.

Key takeaways

  1. The gap between cheapest agent-suitable ($$0.060/M total) and premium reasoning ($$2.00/M+ total) is 33x — this is a token-rate comparison, not a measure of task quality.
  2. A cascade can reduce estimated token charges for some workloads; validate accuracy and retries against an all-reasoning baseline.
  3. Tool schemas, calls, results, and retries consume tokens beyond the visible conversation; measure actual usage.
  4. Prompt caching can help recurring agent calls when cache hits are reliable and model-specific write/storage charges are worthwhile.
Estimate multi-turn agent costs with the calculator →

Pricing data sourced from our catalog. Check data sources for provenance and freshness.