Playbook · $29
AI Agent Cost & Tools Hub

How to calculate AI agent token costs

Short answer: add up every billed token in a model call, multiply by that token type's price per million, then multiply by the number of calls in a task and by how many tasks you run in a month. The model you pick and how often the agent re-reads its context usually move the bill more than anything else.

The formula

Providers bill four token types, each with its own price per 1 million tokens:

Cost per model call:

((uncached input tokens × input price)
 + (cached input tokens × cache-read price)
 + (cache-write tokens × cache-write price)
 + (output tokens × output price))
 ÷ 1,000,000

Cost per task = the sum of every call in that task. If the calls are similar, that is roughly cost per call × calls per task.

Cost per month = cost per task × tasks per day × 30.

Our free AI agent cost calculator uses this formula for input, cached input and output, including an estimated 0.9 × output of reasoning tokens on thinking models for agent workloads. Cache-write fees are not in the calculator or our pricing table, because we do not yet store a cache-write price per model. Add them from your provider's pricing page or bill if they apply. See the methodology for what else is left out.

Each model page uses this same formula and the calculator's presets, with that model's list prices. The walkthrough of those presets lives here rather than on every model page.

Worked example: Claude Sonnet 5.5

We use Claude Sonnet 5.5 and the same example agent as in How much does an AI agent cost per month?: 6 calls (steps) per task, 3,000 input tokens and 400 output tokens per call, 500 tasks a day, 30 days. Prices are the list prices in our table (verified 2026-11-28): $2 per 1M input, $0.1 per 1M cached input and $10 per 1M output. Claude Sonnet 5.5 is a reasoning model, so each call also includes an estimated 0.9 × 400 = 360 reasoning tokens, billed at the output price.

With no caching, one call costs:

(3,000 × $2 + 0 × $0.1 + (400 + 360) × $10) ÷ 1,000,000
 = $0.0136
ScopeNo caching70% of input cached
One call$0.0136$0.00961
One task (6 calls)$0.0816$0.05766
One month (500 tasks/day)$1,224.00$864.90

Inputs (No caching): 6 steps/task × 500 tasks/day × 30 days; 3,000 input tokens/step, 0% cached; 400 output tokens/step; reasoning 0.9 × output on reasoning models (360/step, billed as output).

Inputs (70% cached): 6 steps/task × 500 tasks/day × 30 days; 3,000 input tokens/step, 70% cached; 400 output tokens/step; reasoning 0.9 × output on reasoning models (360/step, billed as output).

Prices used for Claude Sonnet 5.5: $2 input · $0.1 cached input · $10 output, per 1M tokens.

Includes estimated reasoning tokens. Claude Sonnet 5.5 supports reasoning, so agent workloads add 0.9 × output tokens of hidden thinking per step, billed at the output price (the chatbot preset uses 0). Set Reasoning × output to 0 in the calculator to exclude it.

Formula: steps × (uncached input × input price + cached input × cached price + (output + reasoning) × output price) ÷ 1M × tasks/day × 30; reasoning = 0.9 × output on reasoning models for agent workloads (Chatbot preset 0), 0 on other models. Same function as the calculator and MCP server.

Caching does not change the output line, which is why the saving is smaller than the cache-read discount alone. Plug the same numbers into the calculator, or compare Claude Sonnet 5.5 with other models on the pricing table.

What drives cost in an agent loop

The biggest practical levers after you understand the formula are a cheaper model for easy steps, caching, and shorter prompts. How to reduce LLM token costs walks through them, and Cheapest LLM for AI agents compares low-cost options.

FAQ

What is the difference between cost per task and cost per month?

Cost per task is one finished job, including every model call in that run. Cost per month is that figure × how many tasks you start in a day × 30. If some tasks fail, you still paid for them; divide by successful tasks if you want a cost per successful run.

Why might the calculator total differ from a quick tokens × price estimate?

A quick estimate often misses steps, cached-input prices, or reasoning tokens billed as output. Our calculator includes those for input, cache reads and output. It does not include cache-write fees, tool charges, taxes or negotiated rates.

Are cache-write fees included in this example?

No. We show the formula so you can add them, but our pricing data and calculator do not yet include a cache-write price. If your provider charges one, add cache-write tokens × that price per million for each write.

How do I get token counts from a real run?

Use the usage object on each API response, or your provider dashboard. Add up uncached input, cache reads, cache writes, output and reasoning across every call in the task, then type the averages into the calculator.

Try it with your own numbers: the free AI agent cost calculator shows the monthly cost for 10 popular models in seconds.

Want a step-by-step method? The AI Agent Cost Playbook (36-page PDF + spreadsheet, $29 + tax) walks you through cutting your bill in one afternoon. Free sample.

Prices are list prices per million tokens from our pricing table (last refresh 2026-11-28); check providers before you commit. This guide was written with help from AI tools and checked by a human. See also: model vs model cost comparisons and recent price changes.

Newsletter

Weekly LLM & agent pricing changes and cost tips. Free.