
AI & Machine Learning10 min read2,265 words
How Much Does It Cost to Build an AI Agent?
An AI agent costs a one-off build plus a per-task run cost that grows with every step. The cost components, a token formula and a worked example with prices.
Jishu Labs
An AI agent has two costs that behave differently. Building it is a one-off cost, mostly people's time. Running it is a cost per task, mostly model tokens, and it grows with every step the agent takes. A credible answer to what an agent costs is therefore a formula filled in with your own assumptions, not a single price.
Disclosure: Jishu Labs, which publishes this blog, builds custom software for clients, including AI agents. Below are the cost components, a token formula for multi-step agents with prices from vendor pricing pages read on November 25, 2026, and a worked example with stated assumptions. For single-call features, see how to estimate the cost of an AI feature.
What are the cost components of an AI agent?
An AI agent's cost has nine components: discovery, the build, integrations and tools, an evaluation set, guardrails, model usage per task, hosting, monitoring and ongoing tuning. The first five are mostly one-off engineering time. The last four recur every month the agent runs, and model usage scales with the number of tasks.
| Component | What it covers | When you pay | What drives the size |
|---|---|---|---|
| Discovery | The task, the success measure, the data and tools needed, and what the agent must never do | Once | How many systems and teams the task touches |
| Build | The agent loop, prompts, state, error handling and the interface people use | Once | Steps and branches in the task |
| Integrations and tools | Each API, database or internal system the agent calls, with authentication and rate limits | Once, plus upkeep | Number and quality of the APIs; write access needs more care than read access |
| Evaluation set | Real tasks with known good outcomes, and a harness that runs them on every change | Once, then grows | Variety of tasks; whether outcomes can be checked automatically |
| Guardrails | Input and output checks, permission limits and approval steps for risky actions | Once | What the agent is allowed to change |
| Model usage | Tokens for every model call in every task | Per task | Steps per task, context size and model choice |
| Hosting | The servers or functions that run the loop, plus queues, storage and logs | Monthly | Volume and latency targets |
| Monitoring | Traces, cost per task, sampled quality review and alerts | Monthly | Volume and the share of tasks a person reviews |
| Ongoing tuning | Updating prompts, tools and the evaluation set as models, APIs and the business change | Monthly | How fast those upstream things change |
The evaluation set is the easiest line to leave out of a budget, and it is the one that tells you whether a cheaper model or a shorter prompt still works. The guide to evaluating an AI agent before production covers what goes in it.
What is the formula for an AI agent's total cost?
An AI agent's first-year cost is the build cost plus twelve months of running cost. The build cost is estimated hours times rates for the one-off components. The running cost is tasks per month times the cost per task, plus hosting, monitoring and tuning time. Cost per task combines model usage, tool fees and human review.
Build cost = sum of (hours per one-off component x rate of the role)
Cost per task = model usage + tool and search fees + human review
Monthly run cost = tasks per month x cost per task
+ hosting + monitoring + tuning hours x rate
First-year cost = build cost + 12 x monthly run cost
Estimate build hours as for any software project: ranges per component, with unfamiliar integrations priced as separate time-boxed spikes. The part specific to agents, and the easiest to get wrong, is model usage per task.
How do you calculate model cost per task for an agent?
Model cost per task is the sum of every model call in the task. Each call is billed for the whole context sent with it, and an agent resends its system prompt, tool definitions and the growing history of earlier steps on every call. Input tokens therefore grow faster than the number of steps.
Anthropic's pricing page lists what that context includes: the tools parameter, every tool_use and tool_result block, and a tool-use system prompt the API adds automatically, 286 tokens on Claude Sonnet 5.5. Four quantities are enough to estimate any loop:
n = model calls per task
F = tokens sent on every call: system prompt + tool definitions + the task
a = tokens each step adds to the history: the tool call + the tool's result
o = output tokens per call, including thinking tokens
Input tokens per task = n x F + a x n x (n - 1) / 2
Output tokens per task = n x o
With prompt caching, assuming each call starts within the cache lifetime,
each call reads the previous prompt from cache and writes only the new step:
Cache reads = (n - 1) x F + a x (n - 1) x (n - 2) / 2
Cache writes = F + (n - 1) x a
The quadratic term is why long agent runs cost more than expected: the history from step one is paid for again at every later step. Prompt caching does not remove those tokens, but it bills them at the cache-read rate instead of the full input rate.
A worked example: the cost per task of a refund agent
Take an agent that resolves a customer refund request: it reads the ticket, looks up the order, checks the refund policy, calls the payments API and drafts a reply. The assumptions below are illustrative, chosen to show the arithmetic. Count your own task's tokens with each vendor's token counter before relying on any figure.
Illustrative assumptions
n = 8 model calls per task
F = 6,000 tokens system prompt, tool definitions, the ticket
a = 1,500 tokens tool call plus tool result, per step
o = 400 tokens output per call, including thinking
Tokens per task
Input = 8 x 6,000 + 1,500 x 8 x 7 / 2 = 90,000
Output = 8 x 400 = 3,200
Largest single prompt = 6,000 + 7 x 1,500 = 16,500
Claude Sonnet 5.5, list prices as of November 2026, per million tokens:
input $2, output $10, 5-minute cache write $2.50, cache read $0.10
Without caching (90,000 x $2 + 3,200 x $10) / 1,000,000 = $0.212
With caching (73,500 reads x $0.10 + 16,500 writes x $2.50
+ 3,200 output x $10) / 1,000,000 = $0.081
At 20,000 tasks a month: $4,240 without caching, $1,612 with it.
| Model | List price per million tokens, input / output, as of November 2026 | Cost per task without caching |
|---|---|---|
| Claude Haiku 5.5 | $0.10 / $0.50 (prompts up to 100,000 tokens) | $0.011 |
| Claude Sonnet 5.5 | $2 / $10 | $0.212 |
| OpenAI gpt-6.2-sol | $2 / $10 (standard tier) | $0.212 |
| Claude Opus 5.5 | $4 / $20 | $0.424 |
| Google Gemini 4 Carbon | $4 / $20 from December 1, 2026 | $0.424 |
Model choice alone moves the same task's cost by a factor of 40 across this table, which is why routing easy steps to a small model matters. Two cautions apply. The same text yields different token counts on different models: Anthropic notes that its tokenizer for Claude 4.7 and later produces about 30% more tokens than the previous one. And prices move: Google lists Gemini 4 Carbon at $2 input and $10 output per million tokens through November 30, 2026, doubling from December 1.
What makes AI agent costs jump?
Five things make an agent's cost per task jump: more steps, which lengthen every later call; large tool results, which every later call resends; retries, which bill a task twice; human review, which can exceed the model cost; and multi-agent designs, which multiply calls. Each one changes a variable in the token formula.
- More steps. Doubling the refund agent from 8 to 16 calls more than triples its input tokens (276,000 against 90,000) and lifts the uncached cost from $0.212 to $0.616 per task. With caching, the same change roughly doubles the cost, from $0.081 to $0.160.
- Large tool results. Returning a whole document instead of the relevant record, 6,000 tokens per step instead of 1,500, takes input to 216,000 tokens and the uncached cost to $0.464.
- Retries. A task that fails and restarts is billed again in full, so a restart rate of 15% adds 15% to the model line.
- Human review. Illustrative: a person spending three minutes on one task in ten, at a loaded cost of $60 an hour, adds $0.30 per task on average, nearly four times the cached model cost.
- Multi-agent designs. Anthropic reported in June 2025 that, in its data, agents used about 4x more tokens than chat interactions and multi-agent systems about 15x more. Read when one agent beats many before splitting a task.
Where the first-year money goes in the example
Illustrative: two engineers for eight weeks at 35 productive hours a week and a blended $100 an hour is a $56,000 build. Add 20,000 tasks a month at the cached $0.081, the review above at $6,000 a month and 16 tuning hours a month at the same rate, and the first year comes to about $166,500 before hosting and monitoring. People's time is about 88% of that; tokens are about 12%.
How do you cap what an AI agent costs?
Cap an agent's cost at three levels: per call, with an output token limit; per task, with a maximum number of steps and a token budget that hands the task to a person when reached; and per month, with budget alerts and spending limits at each provider. Then reduce what each task needs, starting with caching.
- Cache the stable prefix. On Claude Sonnet 5.5 a cache read costs $0.10 per million tokens against $2 for uncached input, as of November 2026. Anthropic's cache lasts five minutes by default, is refreshed free each time it is read, and is invalidated entirely by any change to the tool definitions.
- Put the tools and system prompt first and keep them fixed; put the task and its history after them.
- Return only the fields the agent needs from each tool, and drop or summarise old tool results once they have been used.
- Route simple steps such as classification or extraction to a smaller model, and run the evaluation set before and after.
- Batch work that can wait. As of November 2026, Anthropic's Batch API is 50% off standard rates, OpenAI's batch prices for gpt-6.2-sol are half its standard rates, and Google lists a 50% cost reduction for its Batch API.
- Record tokens and cost for every task next to its outcome, so a cost increase can be traced to the change that caused it.
A copyable AI agent cost estimate
The template below puts the cost components, the token profile and the caps on one page that a buyer and a builder can both check. Fill in ranges rather than single numbers, record where each price came from and on what date, and keep the token profile separate from the prices, so a price change means re-pricing, not re-measuring.
AI AGENT COST ESTIMATE
Prices checked on: <date> Sources: <vendor pricing page URLs>
Task: <one sentence, what the agent does from start to finish>
Volume: <tasks per month now, and in 12 months>
BUILD (one-off) hours low / likely / high rate cost
Discovery
Agent loop, prompts, state
Integrations (one line each)
Evaluation set and harness
Guardrails and approvals
Total build
COST PER TASK typical heavy (90th percentile)
Model calls per task (n)
Fixed tokens per call (F)
Tokens added per step (a)
Output tokens per call (o)
Model and its four prices
Model cost, uncached / cached
Tool and search fees
Retry rate
Human review (share x minutes x loaded rate)
Cost per task, all in
MONTHLY RUN
Tasks x cost per task
Hosting and storage
Monitoring and tracing
Tuning hours x rate
Total per month
FIRST YEAR = build + 12 x monthly run
CAPS: max steps per task | token budget per task | monthly alert and limit
If you want an outside team to scope, build and run an agent against a cost model like this one, Jishu Labs offers AI agent development.
Frequently Asked Questions
How much does an AI agent cost per task?
It depends on the number of model calls, the context each call carries and the model. In the illustrative eight-step refund agent above, one task costs about $0.21 on Claude Sonnet 5.5 without caching and about $0.08 with caching, at list prices as of November 2026. Measure your own tasks before planning around these figures.
Is a fixed workflow cheaper than an agent?
Usually. In a workflow, code decides the steps and the model fills in specific parts, so there are fewer and shorter calls and no tokens spent deciding what to do next. Use an agent where the steps cannot be known in advance, and a workflow everywhere else.
Does prompt caching work across different tasks?
For the identical part of the prompt, yes. Tool definitions and the system prompt can be shared across tasks while the cache is alive, five minutes by default on Anthropic's API and refreshed each time it is read. The task text and its history are unique, so they are cached only within the task.
Should an estimate assume today's model prices?
Use today's prices with the date next to them, and treat them as a variable. Prices move in both directions: Gemini 4 Carbon's list price doubles on December 1, 2026. Keeping the token profile separate from the prices lets you re-price an estimate without measuring the task again.
References
- Pricing — Anthropic, Claude API documentation
- Prompt caching — Anthropic, Claude API documentation
- Pricing — OpenAI API documentation
- Gemini Developer API pricing — Google AI for Developers
- How we built our multi-agent research system — Anthropic Engineering
About Jishu Labs
Jishu Labs is a software development company founded in 2016. We build custom software, AI/ML systems, and full-stack web and mobile applications for clients, and we make eight AI tools for software teams.




