# How Much Does It Cost to Build an AI Agent?

- Tool: Any LLM or framework
- Difficulty: Beginner
- Time required: 30-40 min
- Compatibility: Python 3.10+, any LLM API key (Claude, OpenAI, or Gemini), works with any agent framework
- Last updated: November 2026

## 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.

## 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.

## Before you start

- 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.

```
INPUT_PRICE = 2.00 / 1_000_000   # $/token, Claude Sonnet 5.5
OUTPUT_PRICE = 10.00 / 1_000_000

def turn_cost(input_tokens, output_tokens):
    return input_tokens * INPUT_PRICE + output_tokens * OUTPUT_PRICE

print(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.

```
monthly_cost = turn_cost(8000, 500) * 2 * 5000
print(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.

```
CACHE_HIT_PRICE = INPUT_PRICE * 0.05  # 5% of input price on a cache hit

def turn_cost_cached(cached_tokens, fresh_tokens, output_tokens):
    return (cached_tokens * CACHE_HIT_PRICE + fresh_tokens * INPUT_PRICE
            + output_tokens * OUTPUT_PRICE)

print(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.

```
class CostTracker:
    def __init__(self, prices):
        self.prices = prices
        self.log = []

    def record(self, model, usage):
        p = self.prices[model]
        cost = (usage.input_tokens * p["input"]
                 + usage.output_tokens * p["output"]
                 + getattr(usage, "cache_read_input_tokens", 0) * p["cache_hit"])
        self.log.append({"model": model, "cost": cost})
        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.

```
def pick_model(task_complexity):
    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.

```
def monthly_estimate(conversations, avg_turns, cost_per_turn):
    return conversations * avg_turns * cost_per_turn

print(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 code example

File: `cost_tracker.py`

```python
"""Token-level cost tracker for an AI agent, plus a monthly cost estimator.
Run: python cost_tracker.py
"""
from dataclasses import dataclass


PRICES = {
    # $ per token. Source: Anthropic pricing, Nov 2026.
    "claude-opus-5-5":   {"input": 4.00 / 1_000_000, "output": 20.00 / 1_000_000, "cache_hit": 0.20 / 1_000_000},
    "claude-sonnet-5-5": {"input": 2.00 / 1_000_000, "output": 10.00 / 1_000_000, "cache_hit": 0.10 / 1_000_000},
    "claude-haiku-5-5":  {"input": 0.10 / 1_000_000, "output": 0.50 / 1_000_000,  "cache_hit": 0.01 / 1_000_000},
}


@dataclass
class Usage:
    input_tokens: int
    output_tokens: int
    cache_read_input_tokens: int = 0


class CostTracker:
    """Logs the dollar cost of every model call, keyed by model."""

    def __init__(self, prices=PRICES):
        self.prices = prices
        self.log: list[dict] = []

    def record(self, model: str, usage: Usage) -> float:
        p = self.prices[model]
        cost = (
            usage.input_tokens * p["input"]
            + usage.output_tokens * p["output"]
            + usage.cache_read_input_tokens * p["cache_hit"]
        )
        self.log.append({"model": model, "cost": cost, "usage": usage})
        return cost

    def total(self) -> float:
        return sum(row["cost"] for row in self.log)

    def by_model(self) -> dict:
        out: dict = {}
        for row in self.log:
            out[row["model"]] = out.get(row["model"], 0.0) + row["cost"]
        return out


def pick_model(task_complexity: str) -> str:
    """Route simple sub-tasks to a cheaper model."""
    return "claude-haiku-5-5" if task_complexity == "simple" else "claude-sonnet-5-5"


def monthly_estimate(conversations: int, avg_turns: float, cost_per_turn: float) -> float:
    return conversations * avg_turns * cost_per_turn


def main():
    tracker = CostTracker()

    # Simulate one support conversation: a lookup (routed to Haiku) then a reply (Sonnet).
    tracker.record(pick_model("simple"), Usage(input_tokens=2000, output_tokens=100))
    tracker.record(
        pick_model("complex"),
        Usage(input_tokens=1000, output_tokens=500, cache_read_input_tokens=7000),
    )

    print("This conversation's cost by model:", tracker.by_model())
    print("This conversation's total cost: $%.4f" % tracker.total())

    projected = monthly_estimate(
        conversations=5000, avg_turns=1, cost_per_turn=tracker.total()
    )
    print("Projected monthly cost at 5,000 conversations: $%.2f" % projected)


if __name__ == "__main__":
    main()
```

## Common mistakes

- **Pricing only the output tokens and forgetting the system prompt and tool schemas count as input on every turn** — undefined Fix: 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.
- **Quoting a single number for 'what an agent costs' without separating build cost from run cost** — undefined Fix: 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.
- **Estimating run cost from a model's list price with no caching assumption** — undefined Fix: 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.
- **Sending every step, including trivial lookups, to your most capable and most expensive model** — undefined Fix: Route simple classification and extraction steps to a cheaper model. It's usually the single biggest lever after caching.
- **Finding out run cost jumped from the monthly invoice instead of from your own logs** — undefined Fix: 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.

## Use cases

### undefined



### undefined



### undefined



## 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.

---

Source: https://www.rapidevelopers.com/build-ai-agent/how-much-does-it-cost-to-build-an-ai-agent
© RapidDev — https://www.rapidevelopers.com/build-ai-agent/how-much-does-it-cost-to-build-an-ai-agent
