Skip to main content
RapidDev - Software Development Agency
build-ai-agent

How Much Does It Cost to Build an AI Agent?

Building an AI agent costs two very different things: a one-time build (roughly $5K-$50K DIY to $60K-$300K+ for agency-built multi-agent systems) and a monthly run cost driven almost entirely by tokens re-sent on every step. This guide works through both with real numbers for a support agent, then builds a Python wrapper that logs the exact dollar cost of every API call. Budget 30-40 minutes to read and run it.

What you'll learn

  • Separate one-time build cost from ongoing run cost, since completely different levers drive each one
  • Work through real per-task token math for a support agent on a current frontier model
  • See where DIY, agency, and enterprise build costs actually land in 2026, and why the ranges are so wide
  • Build a cost-tracking wrapper that logs the dollar cost of every single agent step
  • Identify the two levers, prompt caching and model routing, that cut run cost the most
Book a free consultation
4.9Clutch rating ⭐
1,000+Happy partners
20+Countries served
200+Team members
Beginner10 min read30-40 minPython 3.10+, any LLM API key (Claude, OpenAI, or Gemini), works with any agent frameworkLast updated November 2026RapidDev Engineering Team
TL;DR

Building an AI agent costs two very different things: a one-time build (roughly $5K-$50K DIY to $60K-$300K+ for agency-built multi-agent systems) and a monthly run cost driven almost entirely by tokens re-sent on every step. This guide works through both with real numbers for a support agent, then builds a Python wrapper that logs the exact dollar cost of every API call. Budget 30-40 minutes to read and run it.

Quick facts about this guide
FactValue
ToolAny LLM or framework
DifficultyBeginner
Time required30-40 min
CompatibilityPython 3.10+, any LLM API key (Claude, OpenAI, or Gemini), works with any agent framework
Last updatedNovember 2026

What you'll build

You'll cost out a support agent that handles roughly 5,000 conversations a month for a mid-size SaaS company, the kind of agent that answers 'where's my order' and 'how do I reset my password' and escalates the rest. That's a concrete enough scope to do real math on, instead of the vague 'it depends' that most cost pages leave you with.

Agent cost splits into two numbers that barely correlate with each other. Build cost is what you pay once to design, integrate, and test the thing: it scales with how many systems it touches, whether it needs human-approval workflows, and how much error handling production actually requires. Run cost is what you pay every month after that, and it's driven almost entirely by tokens: your system prompt, tool definitions, and conversation history get re-sent on every single step, not just once per conversation.

This guide gives you real ranges for build cost from 2026 agency and vendor pricing guides, then builds the run-cost side yourself: a worked token calculation for one conversation, scaled to a monthly estimate, with a small Python wrapper that tracks the actual dollar cost of every API call you make. By the end you'll have a number for your own use case, not someone else's average.

Prerequisites

  • Python 3.10+ (pip install anthropic)
  • An API key for the model you plan to use (this guide prices Claude; the same math applies to any provider)
  • A rough guess at your monthly conversation or task volume
  • Basic comfort reading a pricing table

Step-by-step guide

1

Scope the build: what actually makes an agent $5K or $150K

Before any token math, separate what you're building. A single-purpose agent with one or two tools and no approval workflow is a $5K-$50K build in most 2026 agency pricing guides. A mid-tier agent with memory, multiple API integrations, and a human-approval step for risky actions runs $20K-$80K, with many vendors quoting $40K-$120K as the typical range for a real business deployment. A multi-agent system coordinating several specialized agents against several systems of record is where $60K-$150K and up shows up, with full enterprise builds reported at $180K-$300K or more. The variable that moves the number most isn't the LLM, it's integration count and how much the workflow has to be hardened against failure.

Expected result: A rough build-cost bracket for your own agent based on tool count and approval complexity, before you write a line of code.

2

Work through the token math for one conversation

Price a single support turn: roughly 8,000 input tokens (system prompt, tool schemas, and recent history) and 500 output tokens, on a current mid-tier model. At $2 per million input tokens and $10 per million output tokens, that's about 2 cents a turn uncached. Do this calculation for your own prompt size before you estimate anything at scale; most teams guess low because they forget tool schemas and history count as input tokens too.

typescript
1INPUT_PRICE = 2.00 / 1_000_000 # $/token, Claude Sonnet 5.5
2OUTPUT_PRICE = 10.00 / 1_000_000
3
4def turn_cost(input_tokens, output_tokens):
5 return input_tokens * INPUT_PRICE + output_tokens * OUTPUT_PRICE
6
7print(turn_cost(8000, 500)) # ~0.021

Expected result: A per-turn dollar figure, around $0.02 for this example, that you can sanity-check against your own prompt size.

3

Scale one conversation to a monthly run-rate

Multiply the per-turn cost by turns per conversation and conversations per month. A support conversation that takes 2 back-and-forth turns before resolving, at 5,000 conversations a month, lands around $210 a month uncached on this model, before any caching discount. This is the number vendors mean when they say 'assisted' agent run cost sits in the low hundreds a month; it climbs fast once an agent takes more autonomous steps per task.

typescript
1monthly_cost = turn_cost(8000, 500) * 2 * 5000
2print(monthly_cost) # ~210.00

Expected result: A monthly dollar estimate you can compare against the $150-600/month range vendors quote for assisted agents.

4

Add prompt caching to the model

Once your system prompt and tool definitions stop changing between calls, a cache hit on Claude prices that repeated prefix at 2.5-10% of normal input cost instead of full price. Since the system prompt and tool schemas are most of the 8,000 input tokens in this example, caching cuts the real monthly number sharply. Model your cost with and without caching so you know how much a stable, unchanging system prompt is actually worth.

typescript
1CACHE_HIT_PRICE = INPUT_PRICE * 0.05 # 5% of input price on a cache hit
2
3def turn_cost_cached(cached_tokens, fresh_tokens, output_tokens):
4 return (cached_tokens * CACHE_HIT_PRICE + fresh_tokens * INPUT_PRICE
5 + output_tokens * OUTPUT_PRICE)
6
7print(turn_cost_cached(7000, 1000, 500)) # ~0.0097, vs ~0.021 uncached

Expected result: A per-turn cost roughly half to a fifth of the uncached number, depending on how much of the prompt is stable.

5

Build a cost-tracking wrapper around your API calls

Wrap your model calls so every single one logs exactly what it cost, using the usage fields the API already returns (input tokens, output tokens, and cached tokens). Without this, teams find out their actual run cost from the monthly invoice, weeks after a change made it jump. With it, you can see which step in a multi-step agent is burning the budget.

typescript
1class CostTracker:
2 def __init__(self, prices):
3 self.prices = prices
4 self.log = []
5
6 def record(self, model, usage):
7 p = self.prices[model]
8 cost = (usage.input_tokens * p["input"]
9 + usage.output_tokens * p["output"]
10 + getattr(usage, "cache_read_input_tokens", 0) * p["cache_hit"])
11 self.log.append({"model": model, "cost": cost})
12 return cost

Expected result: A running log you can sum or chart, with a dollar cost attached to every step, not just a total at the end of the month.

6

Route cheap steps to a cheaper model

Not every step in an agent needs your most capable model. Classification, extraction, and simple lookups run reliably on a smaller, cheaper model at a fraction of the cost. Routing those sub-tasks off your primary model is usually the single biggest lever after caching, often cutting the cost of a multi-step agent by more than half without touching output quality on the steps that actually need the stronger model.

typescript
1def pick_model(task_complexity):
2 return "claude-haiku-5-5" if task_complexity == "simple" else "claude-sonnet-5-5"

Expected result: A routing function you can drop into your agent loop that sends easy steps to the cheap model automatically.

7

Put it together into a monthly estimate for your own usage

Combine caching and routing into one formula: monthly cost equals conversations times average turns times your blended cost per turn after caching and routing. Run it with your own volume and prompt size instead of this guide's example numbers, since that's the only version of this estimate that actually matters to your budget.

typescript
1def monthly_estimate(conversations, avg_turns, cost_per_turn):
2 return conversations * avg_turns * cost_per_turn
3
4print(monthly_estimate(5000, 2, turn_cost_cached(7000, 1000, 500))) # ~97

Expected result: A single monthly dollar figure for your own conversation volume, built from numbers you can defend line by line.

Complete working example

cost_tracker.py
1"""Token-level cost tracker for an AI agent, plus a monthly cost estimator.
2Run: python cost_tracker.py
3"""
4from dataclasses import dataclass
5
6
7PRICES = {
8 # $ per token. Source: Anthropic pricing, Nov 2026.
9 "claude-opus-5-5": {"input": 4.00 / 1_000_000, "output": 20.00 / 1_000_000, "cache_hit": 0.20 / 1_000_000},
10 "claude-sonnet-5-5": {"input": 2.00 / 1_000_000, "output": 10.00 / 1_000_000, "cache_hit": 0.10 / 1_000_000},
11 "claude-haiku-5-5": {"input": 0.10 / 1_000_000, "output": 0.50 / 1_000_000, "cache_hit": 0.01 / 1_000_000},
12}
13
14
15@dataclass
16class Usage:
17 input_tokens: int
18 output_tokens: int
19 cache_read_input_tokens: int = 0
20
21
22class CostTracker:
23 """Logs the dollar cost of every model call, keyed by model."""
24
25 def __init__(self, prices=PRICES):
26 self.prices = prices
27 self.log: list[dict] = []
28
29 def record(self, model: str, usage: Usage) -> float:
30 p = self.prices[model]
31 cost = (
32 usage.input_tokens * p["input"]
33 + usage.output_tokens * p["output"]
34 + usage.cache_read_input_tokens * p["cache_hit"]
35 )
36 self.log.append({"model": model, "cost": cost, "usage": usage})
37 return cost
38
39 def total(self) -> float:
40 return sum(row["cost"] for row in self.log)
41
42 def by_model(self) -> dict:
43 out: dict = {}
44 for row in self.log:
45 out[row["model"]] = out.get(row["model"], 0.0) + row["cost"]
46 return out
47
48
49def pick_model(task_complexity: str) -> str:
50 """Route simple sub-tasks to a cheaper model."""
51 return "claude-haiku-5-5" if task_complexity == "simple" else "claude-sonnet-5-5"
52
53
54def monthly_estimate(conversations: int, avg_turns: float, cost_per_turn: float) -> float:
55 return conversations * avg_turns * cost_per_turn
56
57
58def main():
59 tracker = CostTracker()
60
61 # Simulate one support conversation: a lookup (routed to Haiku) then a reply (Sonnet).
62 tracker.record(pick_model("simple"), Usage(input_tokens=2000, output_tokens=100))
63 tracker.record(
64 pick_model("complex"),
65 Usage(input_tokens=1000, output_tokens=500, cache_read_input_tokens=7000),
66 )
67
68 print("This conversation's cost by model:", tracker.by_model())
69 print("This conversation's total cost: $%.4f" % tracker.total())
70
71 projected = monthly_estimate(
72 conversations=5000, avg_turns=1, cost_per_turn=tracker.total()
73 )
74 print("Projected monthly cost at 5,000 conversations: $%.2f" % projected)
75
76
77if __name__ == "__main__":
78 main()
79

Common mistakes

Why it's a problem: Pricing only the output tokens and forgetting the system prompt and tool schemas count as input on every turn

How to avoid: Count your actual system prompt and tool definition length in tokens before estimating. On a short support exchange, that fixed overhead is often most of the cost.

Why it's a problem: Quoting a single number for 'what an agent costs' without separating build cost from run cost

How to avoid: Always give two numbers: a one-time build range and a monthly run-rate range. They're driven by completely different variables and conflating them misleads whoever's approving the budget.

Why it's a problem: Estimating run cost from a model's list price with no caching assumption

How to avoid: Model both the uncached and cached cost. A stable system prompt and tool list routinely cuts the real number by half or more once cache hits kick in.

Why it's a problem: Sending every step, including trivial lookups, to your most capable and most expensive model

How to avoid: Route simple classification and extraction steps to a cheaper model. It's usually the single biggest lever after caching.

Why it's a problem: Finding out run cost jumped from the monthly invoice instead of from your own logs

How to avoid: Wrap every model call with a cost tracker that logs tokens and dollars per step, so a regression shows up the day it happens, not the day the bill arrives.

Best practices

  • Always quote build cost and run cost as two separate numbers, never one blended figure.
  • Model your own token counts from a real system prompt and tool schema, not a generic estimate.
  • Track cached vs. uncached input tokens separately; they can differ in price by 10-20x.
  • Route sub-tasks to a cheaper model by default, and only escalate to the expensive one when a step actually needs it.
  • Log cost per step, not just per conversation, so you can see which part of a multi-step agent is expensive.
  • Re-run your cost estimate whenever you add a tool, a retry loop, or a longer history window; all three increase input tokens.
  • Treat vendor-quoted build-cost ranges as brackets, not quotes; get a scoped estimate once you know your own integration count.

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I have this Python cost-tracking wrapper for an AI agent (below), pricing Claude Opus, Sonnet, and Haiku per token with caching. Extend it to also price OpenAI and Gemini models, and add a method that prints a monthly cost breakdown by model. [paste complete_code]

Build AI Agents Prompt

In Claude Code, open cost_tracker.py and ask: 'Add a budget alert that raises an exception if CostTracker.total() crosses a dollar threshold I pass in, and show me how to call it from inside an agent loop.'

Frequently asked questions

How much does it cost to build a simple AI agent?

A single-purpose agent with one or two tools and no approval workflow typically runs $5K-$50K to build in 2026 agency pricing guides, with monthly run cost in the low hundreds of dollars for moderate volume.

Why do AI agent cost estimates vary so much, from $5K to $300K?

The spread comes from integration count and workflow complexity, not the model itself. A single-tool agent and a multi-agent system coordinating five internal tools with human-approval gates are different projects that happen to share the word 'agent.'

What's the biggest lever for cutting an agent's monthly run cost?

Prompt caching first, since it discounts the repeated system prompt and tool schema tokens that make up most of a short turn's input cost. Routing simple sub-tasks to a cheaper model is the second-biggest lever.

Does using a cheaper model always save money on an agent?

Only if the cheaper model handles the task reliably enough that you're not paying for retries, escalations, or a human fixing mistakes afterward. Route by task complexity, not by a blanket rule to use the cheapest model everywhere.

How much does an AI voice agent cost to run compared to a text agent?

Voice adds a per-minute cost on top of the same token math, typically $0.05-$0.30 per minute depending on the speech-to-text, text-to-speech, and telephony stack, so a 5-minute call usually costs more than a 5-turn text conversation.

How much does RapidDev charge to build a custom AI agent?

RapidDev's standard engagements for a production agent run $13K-$25K, scoped to the integrations and approval workflow you actually need, below the $20K-$80K+ range many agencies quote for comparable mid-tier builds. A free 30-minute consultation gets you a real number for your use case.

RapidDev

Talk to an Expert

Our team has built 1,000+ apps. Get personalized help with your project.

Book a free consultation
Matt Graham

Written by

Matt Graham · CEO & Founder, RapidDev

1,000+ client projects delivered. Columbia University & Harvard Business School alumnus, U.S. Navy veteran. About the author →

Learning is great. Shipping is faster with help.

Our engineers have built 1,000+ apps on your platform and the tools around it. If your project needs to be live sooner than your learning curve allows — book a free consultation.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.