Skip to content
AI Infrastructure

How Much Does It Cost to Run an AI Agent in Production? A Token-Economics Breakdown

Agent cost isn't tokens times price — it's the conversation history you resend on every turn. A cited pricing table across Anthropic, OpenAI, and Google, plus an interactive calculator that models what prompt caching actually saves.

Published · How this was researched

Back to Global Tech Search

Market Horizon

2026-2027

Target Sector

AI Engineering, Agent Builders, Solo & Small-Team Developers

Cheapest Output

$1.50/1M

Gemini 3.1 Flash, official pricing

Most Expensive

$168/1M

GPT-5.2 Pro output, official pricing

Cache Read Discount

90%

Off input price, Anthropic's own docs

Cache Write Premium

1.25x

5-min TTL, Anthropic's own docs

Why 'Tokens × Price' Undercounts By A Lot

An agent isn't one request. It's N requests, growing.

Most “how much does an AI agent cost” posts multiply an expected number of tokens by a provider's list price and stop there. That works for a single request-response call. It breaks down for an agent, because the Messages/Chat Completions APIs are stateless — every tool-calling turn re-sends the entire conversation history as input, not just the new message. A 20-turn agent run doesn't cost 20x a single turn; it costs roughly 20x the average context size across those turns, which is much larger than the first turn and much smaller than the last one, and without prompt caching every one of those resends is billed at full input price.

This is also exactly where prompt caching earns its keep, and why a cost estimate that ignores it is not just imprecise but structurally wrong for any provider whose agent workloads use caching by default. The rest of this post is built on official pricing figures — no invented per-token numbers — plus a calculator that runs the actual resend-and-cache math instead of a flat multiplication.

Current Pricing, Sourced Directly

Output price is where the real spread is.

As of publishing, Anthropic's current lineup runs Claude Haiku 4.5 at $1/$5 per million input/output tokens, Claude Sonnet 5 at $3/$15 (a $2/$10 introductory rate applies through 2026-08-31), Claude Opus 5 at $5/$25, and Claude Fable 5 — the highest-capability tier — at $10/$50. OpenAI's current models run GPT-5.2 at $1.75/$14, GPT-5.5 at $5/$30, and GPT-5.2 Pro at $21/$168. Google's Gemini 3.1 Flash runs $0.25/$1.50, while Gemini 3.1 Pro runs roughly $2.00/$12.00 for prompts up to 200K tokens (higher above that threshold, per Google's own long-context pricing tiers). The spread on output price alone — $1.50 to $168 per million tokens — is more than 100x, which means model choice is usually a bigger lever than any optimization you can apply to a fixed model.

Output Token Pricing Across Providers

Official pricing pages, accessed 2026-07-28 — sorted highest to lowest

What An Agent Run Actually Costs

Model the resend, not just the tokens.

This calculator simulates an agentic loop turn by turn: each turn adds new tokens (a tool result, a user message) to a growing conversation, re-sends that accumulated context as input, and bills a fresh output. With caching enabled, everything before the newest addition is billed at each provider's cache-read rate instead of full price — for Anthropic that's roughly a 90% discount off input price, per its own published pricing documentation, with only the newest chunk paying a cache-write premium. Try dragging turns from 5 to 50 with caching off, then on — the gap widens dramatically as conversations get longer, which is exactly when caching matters most.

Prompt caching
Gemini 3.1 Flash
$0.03
Claude Haiku 4.5
$0.11
Claude Sonnet 5
$0.34
GPT-5.2
$0.48
Claude Opus 5
$0.57

Simplified simulation, not a vendor-published benchmark: each turn re-sends the accumulated conversation as input and bills a fresh output. With caching on, everything before the newest turn is billed at each provider's cache-read rate (Anthropic: ~0.1x input price, per its published pricing docs) and only the new chunk pays the cache-write premium (~1.25x for Anthropic's 5-minute default); OpenAI and Google cache discounts are modeled from their own published multipliers. Real agent runs vary — tool-result size, system-prompt size, and thinking-token overhead all shift the actual number. Prices reflect each provider's own pricing pages as of 2026-07-28 and change frequently — verify current rates before budgeting.

Actually Cutting The Bill

Cache the prefix, downgrade the routine steps.

Two levers dominate everything else. Turn on prompt caching and structure prompts so stable content comes first — system prompt and tool definitions before any per-turn variable content — since caching is a strict prefix match and a single byte changed early in the prompt invalidates everything after it. Use a cheaper model for routine steps — tool routing, simple extraction, formatting — and reserve the frontier model for the steps that actually need its reasoning. A multi-model agent that runs Gemini 3.1 Flash or Claude Haiku 4.5 for the bulk of its tool-calling turns and escalates to a frontier model only when a step is genuinely hard can cut blended cost by an order of magnitude versus running every turn on the most expensive model available, without necessarily sacrificing the final answer's quality if the escalation logic is sound.

The honest cost model for an agent isn't a single number per token — it's a function of how many turns the loop runs, how much context each turn adds, and whether the request pattern actually benefits from caching. Run your own numbers through the calculator above before committing to a model for a production agent.

Sources

  • Anthropic model and pricing documentation — Claude Haiku 4.5, Sonnet 5, Opus 5, and Fable 5 per-token pricing; prompt-caching read/write multipliers (~0.1x input for cache reads, 1.25x for 5-minute-TTL cache writes)
  • developers.openai.com/api/docs/pricing and per-model pages — GPT-5.2, GPT-5.5, and GPT-5.2 Pro per-token pricing
  • ai.google.dev/gemini-api/docs/pricing — Gemini 3.1 Flash and Gemini 3.1 Pro per-token pricing, including the >200K-token long-context tier

LLM API pricing changes frequently and providers routinely ship new model versions — figures above reflect each provider's own pricing documentation as accessed on 2026-07-28. The cost calculator is a simplified simulation of caching mechanics, not a guarantee of any specific workload's bill; verify current rates on each provider's pricing page before budgeting a production agent.

Advantages

  • Prompt caching cuts the dominant cost driver dramatically — Anthropic's own pricing docs put cache reads at roughly 10% of the full input price, which compounds heavily as agent conversations grow longer
  • The pricing spread across providers is over 100x on output tokens alone ($1.50 to $168 per million), meaning model choice is usually a bigger cost lever than any prompt optimization on a fixed model
  • A multi-model architecture — cheap model for routine tool-routing steps, frontier model only for genuinely hard reasoning — can cut blended cost by an order of magnitude versus running every turn on the most expensive available model

× Challenges

  • Without caching, agent cost scales worse than linearly with turn count, since every turn re-sends the full accumulated conversation as billable input tokens
  • Caching only helps when the prompt prefix is stable — a single changed byte early in the prompt (a timestamp, a reordered tool list) invalidates the cached prefix and forces a full-price re-write
  • LLM API pricing changes frequently and providers ship new model versions often; every figure in this post should be re-verified against the provider's own pricing page before budgeting a production system

Risk Assessment

The included cost calculator is a simplified simulation of caching mechanics (uniform per-turn token growth, a fixed cache-write multiplier), not a guarantee of any specific workload's actual bill — real agents have variable tool-result sizes, system-prompt overhead, and thinking-token costs that shift the real number in either direction.

Abhishek Kushwaha

Written by Abhishek Kushwaha

Full-stack software engineer in Kathmandu, Nepal — six years shipping production Django and Next.js systems, most recently at Pinakin Technologies & Research Center. Writes Global Tech Search on what the AI buildout costs in power, water and silicon, measuring it first-hand where he can. More about the author →