The Question Everyone Asks After the Demo
An AI agent looks cheap in a demo and expensive in production. The reason is simple: agents loop. Every step re-sends context and generates reasoning tokens, so a "one prompt" task can quietly become dozens of model calls. This guide gives you the real monthly math and the levers that actually move it.
The Cost Formula
An agent's monthly bill is roughly:
steps per task × (input tokens + output tokens) × task volume × model rate
The multiplier people forget is steps per task. A retrieval-augmented, tool-using agent might make 5–20 model calls per user task, each re-sending a growing context window. That's why output tokens and re-sent context — not the first prompt — dominate the bill.
Worked Examples
Assume a moderate agent: ~15 calls per task, ~4K input + ~1K output per call (~75K tokens per task), and 3,000 tasks/month (~225M tokens). Using current rates:
| Model | Rate (in/out per 1M) | ~Monthly cost |
|---|---|---|
| Claude Opus 4.8 | $5 / $25 | ~$1,700 |
| GPT-5.4 | $2.50 / $15 | ~$975 |
| Gemini 2.5 Pro | $1.25 / $10 | ~$560 |
| DeepSeek V4 Flash | $0.14 / $0.28 | ~$45 |
(Rough figures for illustration — your token mix will differ.) The spread is enormous: the same agent can cost $45 or $1,700/month purely on model choice. That's the headline lesson.
The Hidden Cost Drivers
- "Thinking"/reasoning modes bill at the same rate but can consume 3–5x more tokens. Turn them off by default; enable per-task.
- Growing context. Each step re-sends history. Prune aggressively; summarize old turns instead of resending them raw.
- Retry storms. Poor error handling doubles spend without producing more output. Use exponential backoff.
- Runaway loops. An agent that doesn't know when to stop burns tokens indefinitely. Cap steps and add a budget guard.
- The staging experiment nobody turned off. Track spend per feature/environment.
How to Cut It (Biggest Levers First)
- Route by difficulty. Run most steps on a cheap model (DeepSeek V4 Flash, Haiku, Gemini Flash-Lite) and escalate only the hard ones to a flagship. This model-cascade is the single biggest lever — often 5–25x.
- Cache the stable context. Prompt caching cuts repeated input up to ~90% (DeepSeek's auto cache ~98%). Agents that resend the same system prompt/tools every step benefit enormously.
- Batch the non-urgent. 50% off for anything a human isn't waiting on.
- Trim context and cap output. Fewer tokens in and out on every one of those 15 calls compounds.
Full playbook in how to reduce AI API costs.
Build It So Routing Is Trivial
The cheap-default / premium-escalation pattern needs easy model switching. A single-key gateway makes the model one config string — and on LinkModel you get fixed per-request pricing (up to 30% below official) across Claude, GPT, Gemini, and DeepSeek, so your agent can route per step without juggling providers. Architecture in build an AI app with multiple models.
Bottom Line
A production agent typically costs tens to low-thousands of dollars a month, and model choice + routing + caching move that by 10x or more. Estimate with the formula, default to a cheap model, escalate only when needed, cache the stable context, and cap your loops.
Start free with a $1 credit and benchmark your agent's real per-task cost across models before you commit.
