运行一个 AI 智能体要花多少钱?来自 4 个项目的真实数据
原题How much does an AI agent cost to run? Numbers from 4 builds
推荐理由真实项目账单把模型调用、基础设施和静默失败放在一起。开发者可用作者的估算方式检查成本上限,避免只按 token 单价选方案。
读前速览
一位全栈 AI 工程师拆解了四个 AI 智能体项目的真实运行成本,指出模型选择是决定 token 账单的最大因素(每 1,000 步成本相差约 140 倍),但最大的隐性成本在于上下文管理、基础设施,以及防止静默失败的防护措施。
一个 AI 智能体有三个成本计量表,模型只是其中之一。
模型调用、智能体所驱动的系统(代理、浏览器、服务器),以及防止静默失败的防护措施都会产生成本。在全部四个项目中,最便宜的 token 是那些从未发送的 token,而昂贵的工时都花在了模型周边的部分上。
模型选择对 token 账单的影响超过其他任何因素,差距约 140 倍。
1,000 个相同的智能体步骤(输入 4,000 token,输出 500 token)在 DeepSeek V4.1 Flash 上花费 0.46 美元,在 Claude Haiku 5.5 上花费 0.65 美元,在 Claude Opus 5.5 上则要 26 美元。将每条消息路由到最便宜且够用的模型,并删除那些不划算的调用,能最大程度地削减账单。
上下文,而非每 token 的价格,才是 bug 和隐性成本的真正来源。
长会话在上下文溢出时返回乱码文本,保存的检查点变得过大,系统提示词中携带了很少用到的文件。回收会话、将检查点限制在 2 KB、按需加载技能,每次调用可节省数千个 token,同时加快回复速度。
智能体所驱动的基础设施,其成本可能超过模型账单。
一次旅行基准测试运行使用了约 935 MB 的代理流量(约 3.08 美元),屏蔽追踪器将每次搜索的流量从 4.2 MB 降至 2.5 MB,而决定服务器规格的是 CPU 而非内存(8 核上运行 20 个浏览器,负载约 30,剩余 6-7 GB 内存)。
大多数估算都忽略的成本,是让智能体可以安全地无人值守。
真实的失败案例包括:一次 8 天的静默宕机、一个「成功」但返回零行的任务、一次停止后仍持续花费 4 小时的运行,以及 49 分钟内 3,492 条告警(92.4% 为噪音)。这些体现为工时和信任的流失,而非 token 价格。
其余 1 个要点
当输入不能离开本地且模型较小时,端侧 AI 更便宜。
两个开源模型(约 24 MB 权重)在场地自己的电脑上运行,用于直播音频检查,没有按次调用费用,32 个频道约占一台双核服务器的 0.9,代价是必须在真实数据上验证其准确性。
完整摘要
Denys 是一位全栈兼 AI 工程师,他分享了自己构建并运行的四个 AI 智能体系统的实测成本数据:一个个人助理智能体、一个旅行价格基准测试、一个直播音频检查器,以及一个房产证书服务。他认为,运行一个智能体需要三方面的成本——模型调用、它所驱动的系统,以及防止它静默失败的防护措施。模型选择对 token 账单的影响最大:1,000 个相同的智能体步骤在 DeepSeek V4.1 Flash 上花费 0.46 美元,而在 Claude Opus 5.5 上则要 26 美元,相差约 140 倍。在他的项目中,模型调用是最容易控制上限的部分(一次背景检查 0.05 美元,一次完整研究运行的上限为 2.10 美元),而一次基准测试运行的代理流量就花了 3.08 美元,最昂贵的意外来自静默失败,包括一次长达 8 天无人察觉的宕机。他详细介绍了上下文管理的 bug、基础设施的规模选择(决定服务器规格的是 CPU 而非内存)、何时端侧 AI 优于 API,以及大多数估算都会忽略的防护工作。最后,他给出了一个五数字估算框架,并坦诚说明了上限与实际支出之间的差距。
目录 · 11 节
TL;DR
An AI agent costs three things to run: the model calls, the systems it drives, and the guardrails that stop it failing quietly. The model you pick moves the token bill most: a thousand identical agent steps cost USD 0.46 on DeepSeek V4.1 Flash, USD 0.65 on Claude Haiku 5.5 and USD 26 on Claude Opus 5.5. In four systems I built this year, model calls were also the easiest part to cap: USD 0.05 for a background check, USD 2.10 at most for a full research run. Proxy traffic for one price benchmark run cost USD 3.08, and the costly surprises were failures nobody saw, like an outage that ran for 8 days before it was noticed.
I’m Denys, a full-stack and AI engineer. Most articles on this question quote wide ranges with no project behind them. Below are the meters from four things I built and run, with the source of every number: config files, commit messages and measured runs. Where a number is a ceiling I set rather than a bill I paid, I say so.
What do you pay for when you run an AI agent?
Three meters, and the model is only one of them.
| Build | What the AI does | Model cost per unit | What else runs the bill |
|---|---|---|---|
| Personal assistant agent | Chats on Telegram, works the CRM and email, runs web research | USD 0.00065 to 0.026 per step, depending on the model; ceilings from USD 0.05 to 2.10 per run | One server, plus retries and watchdogs |
| Price benchmark for a travel agent | A separate AI agent starts benchmark runs through an MCP server | Zero on my side: that agent pays its own tokens | Proxy traffic, about USD 3.08 per run, and an 8-core server |
| Live broadcast audio check | Detects speech and the spoken language on every channel | Zero per call: two small models run on the site’s own computer | CPU: a 32-channel demo used about 0.9 of a 2-core cloud server |
| Property certificates | Reads unknown portals like a person would | Tokens only for portals the scripts do not know | Scripts handle the known portal with no tokens at all |
The pattern held in all four: the cheapest token is one you never send, and the expensive hours go into the parts around the model.
How much do the model calls cost?
The assistant is the only one of the four where the model bill is mine. It runs on Anthropic’s Claude Agent SDK, and every agent in it has a hard ceiling in code. The SDK stops a run when it reaches the turn limit or the dollar limit.
| Job | Model | Ceiling per run |
|---|---|---|
| Background check while idle | Claude Haiku 4.5 | USD 0.05, and USD 1.00 per day in total |
| Research: split the question | Claude Opus 4.6 | USD 0.10, 1 turn |
| Research: three researchers in parallel | Claude Opus 4.6 | USD 0.50 each, 3 turns, web search and fetch |
| Research: write the answer | Claude Opus 4.6 | USD 0.50, 1 turn |
| Main conversation | Haiku, Sonnet or Opus, see below | 200 turns or USD 50, a safety net rather than an expectation |
So the most a full research run can cost is USD 0.10 + 3 × 0.50 + 0.50 = USD 2.10. That is a ceiling, not an average; what a run really costs depends on the model, which the next section prices.
Two choices cut the bill more than any price change:
- Route each message to the cheapest model that can handle it. Short, simple messages go to Haiku, moderate ones to Sonnet, multi-step ones to Opus. The router reads keywords and message length, so routing itself costs no model call. Early on, every agent ran on Opus.
- Delete calls that do not earn their place. The background check used to ask the model for a status report every cycle. It had no access to email or the CRM, so all it could do was write messages nobody needed. I removed the model call entirely. The USD 1.00 daily cap is still in the config, guarding nothing.
One honest gap: the SDK reports the cost of every call, and I never stored it. The monthly total lives in the Anthropic console, not in the app. If I built it again, I would log cost per call from day one, so you can see which job spends the money, not only how much.
How much does the choice of model change the bill?
More than anything else on the token side. Below, one agent step is priced on different models. The step is about 4,000 tokens in and 500 out, the per-call estimate written into the assistant’s own code for its background check. Prices are OpenRouter’s list on 15 October 2026. OpenRouter passes through each provider’s list price and takes its fee when you buy credits (5.5% on the standard plan), not per request.
| Model | Price per 1M tokens, in / out | One step | 1,000 steps |
|---|---|---|---|
| DeepSeek V4.1 Flash | USD 0.024 / 0.72 | USD 0.00046 | USD 0.46 |
| Claude Haiku 5.5, GPT-6 Luna | USD 0.10 / 0.50 | USD 0.00065 | USD 0.65 |
| Qwen3.8 Flash | USD 0.15 / 0.47 | USD 0.00083 | USD 0.83 |
| Mistral Small 4 | USD 0.15 / 0.60 | USD 0.00090 | USD 0.90 |
| Llama 4 Maverick | USD 0.188 / 0.652 | USD 0.0011 | USD 1.08 |
| Gemini 3.5 Flash Lite | USD 0.30 / 2.50 | USD 0.0025 | USD 2.45 |
| DeepSeek V4 Pro | USD 0.955 / 1.911 | USD 0.0048 | USD 4.78 |
| Gemini 3.8 Flash | USD 0.75 / 3.75 | USD 0.0049 | USD 4.88 |
| Grok 4.7 | USD 2 / 6 | USD 0.011 | USD 11 |
| Claude Sonnet 5.5, GPT-6.1 Sol, Gemini 4 Argon | USD 2 / 10 | USD 0.013 | USD 13 |
| Claude Opus 5.5 | USD 4 / 20 | USD 0.026 | USD 26 |
| Claude Fable 5.1, GPT-6 Astra | USD 10 / 50 | USD 0.065 | USD 65 |
The same work costs from USD 0.46 to USD 65 per thousand steps, a spread of about 140 times. Three things follow:
- A small model handles most steps. Sorting a message, pulling fields from a document, answering from a known text: these rarely need a top model. Keep the large ones for planning and hard reasoning, which is what the routing above does.
- Prices move fast. The assistant ran on Claude Haiku 4.5, Sonnet 4.6 and Opus 4.6. On today’s list, the step costs USD 0.0065 on Haiku 4.5 and USD 0.00065 on Haiku 5.5. Anthropic notes that its newer models count about 30% more tokens for the same text, so per step the newer one is still almost eight times cheaper. Google’s Gemini 4 Argon is due to double its price on 1 December 2026. Re-check before you plan a year ahead.
- Compare tasks, not token prices. A cheaper model that needs two attempts, or a longer prompt to behave, can cost more per finished task. Measure a sample of real tasks on two or three models before you choose.
Your own estimate is one line: steps per task × tasks per month × the step price of your model.
Why was context the real problem, not the price per token?
Price per token is predictable. Context is not. The bugs that hurt this assistant were all about how much text went into each call:
- Long sessions broke replies. To answer faster, the app kept a warm session open between messages. When the context overflowed, the model started returning garbled text in mixed alphabets. The fix: recycle the session after 20 messages and retry in a fresh one when a reply looks broken.
- A saved checkpoint grew too big. One day calls failed with “Prompt is too long”. The checkpoint injected into each call is now capped at 2 KB.
- The system prompt carried files it rarely needed. Loading skills only when a message needs them saved about 3,000 tokens per call, and dropping three reference files from the preload saved about 1,500 more. These are estimates from the commit notes, not invoice lines.
- History was longer than useful. The chat history sent with each call went from 20 messages to 10.
Every one of these lowers cost and speeds up replies at the same time. Treat context as a budget, the same way you treat money.
What does the infrastructure an agent drives cost?
In the travel price benchmark, the AI part is a separate agent. It starts benchmark runs through an MCP server I built, and its tokens are billed to whoever runs that agent. What the benchmark itself pays for is the scraping behind it: residential proxies and a server full of browsers.
Measured numbers from that system:
- Proxy traffic: one run over two travel sites used about 935 MB, about USD 3.08, roughly 0.23 MB per price row saved.
- Blocking trackers: on one site, blocking tracking scripts cut traffic from 4.2 MB to 2.5 MB per search, with identical prices in all six test runs.
- No browser where none is needed: one site’s prices could be read with a plain HTTP client that looks like a mobile browser. Collection went from 8 to 43 dates per minute on five workers, and the browser code for that site was deleted.
- CPU, not memory, sets the server size: with 20 browsers on an 8-core server, load was about 30 while 6 to 7 GB of RAM sat free. A warm browser takes about 345 MB. Size the server by cores.
If your agent drives browsers, proxies or paid APIs, those meters will likely outgrow the model bill. Measure them per task before you choose a model.
When is on-device AI cheaper than an API?
When the input never needs to leave the building and the model is small. The broadcast project checks live audio channels during sports broadcasts: silence, glitches, a commentator switching to the wrong language. Sending every second of audio to an API would cost money on every call and add delay.
Instead, two open models run on the venue’s own computer: one detects speech, the other names the language. Together they hold about 24 MB of weights, the speech detector adds about 7 MB of RAM, and there is no fee per call. In a 32-channel demo, analysing every channel in real time used about 0.9 of a 2-core cloud server.
The trade-off is accuracy you have to prove yourself. On a public set of clean read speech, 30 three-second clips per language, the language model was right 93.3% of the time for Portuguese and at least 96.7% for Spanish, English and French. That is a ceiling, not a forecast: crowd noise and music under a commentator were never measured, because no audio from a real broadcast circuit was available.
What does it cost to make an agent safe to leave alone?
This is the cost most estimates skip, and it is where my hours went. Some real failures:
- An 8-day silent outage. Another project on the same server updated a shared browser cache. The scraper’s pool went from 40 working browsers to 0, jobs hung without an error, and nothing alerted anyone. The fix was small: give the scraper its own browser cache. Finding the cause took 8 days, because there was no alert on pool readiness.
- A job that “succeeded” with nothing. One run went through 359 dates in 12 minutes, saved 0 rows and reported success. Jobs now stop after 25 empty dates in a row and say why.
- A stopped run that kept spending. A benchmark marked as stopped kept running for 4 hours, using proxy traffic the whole time.
- A proxy limit drained the pool. When the proxy plan hit its traffic limit, the pool shrank from 40 browsers to 0 in 12 minutes and stayed there until a restart. It now refills itself every 60 seconds, backing off to 5 minutes.
- Too many alerts on day one. The first test of the broadcast tool on a real 16-channel feed, 49 minutes long, produced 3,492 events. 92.4% were noise and voice-change alerts, and the operator pressed Clear 182 times in 27 minutes. The detectors were fine; the thresholds had never met real programme audio. The fix was a per-profile switch, not new maths.
- Hung calls and rate limits. The assistant now has a 120-second watchdog for a call that goes quiet, a 300-second limit on the whole call, and up to 3 retries after 30 seconds, 2 minutes and 5 minutes when the API is overloaded or rate-limited. A hung tool call does not fall through to the backup models, because a slower model will not fix a stuck tool.
None of this shows up as a token price. It shows up as hours, and as trust lost when the agent says “done” and is wrong. Budget for it: a first test on real data, alerts on the things that can go silent, and checks that a “success” produced something.
Where does AI fit when scripts can do most of the work?
At the edges. The property certificate service collects papers from property managers’ online accounts and builds the certificate a seller needs. A script handles the main known portal, where 95% of documents are completed. Vision AI reads only the portals the scripts do not know, and that path sits behind a switch that turns it off at once.
For the people who order them, a certificate now takes 2 to 3 minutes instead of 2 to 3 weeks, and costs EUR 99 instead of EUR 200 to 300. The AI is the smaller part of that pipeline on purpose: scripts are cheap and predictable where they work, and the model is used where only reading like a person will do.
How do you estimate the running cost of your own agent?
Before you ask for a quote, write down five numbers:
- Tasks per month. Messages, documents, runs.
- Model calls per task, and which model each needs. Most tasks do not need the top model.
- Tokens per call. System prompt, history, documents. This is where costs grow quietly.
- The other meters. Proxies per MB, paid APIs per call, servers per core.
- A ceiling for each job. A per-run dollar cap in code, not only a monthly limit on the account.
Then add the cost nobody quotes: a test on real data in week one, alerts for silent failures, and someone to read them.
What these numbers do not tell you
The ceilings above are limits I set, not what was spent, and the model table is list prices, not my invoices. Every project number comes from one system and one period. Model prices change often, so check the vendors’ current pricing pages before you plan. And none of this says how long the builds took or what they cost to build; that depends on the integrations far more than on the AI.
If you are planning an agent and want to compare notes on what it will cost to run, I am happy to look at your numbers. My AI agent development page shows how I work, and the property certificate case, broadcast audio case and travel price case show three of these builds in more detail. For a bot on WhatsApp, the channel fees often outweigh the model; I worked them out per country in what a WhatsApp AI chatbot costs.
Sources
- Anthropic, Claude Agent SDK options:
max_turnsandmax_budget_usdstop a run; each result reportstotal_cost_usd. - OpenRouter, model list prices and platform fees, read 15 October 2026.
- Anthropic, Claude pricing, and Google, Gemini API pricing, read 15 October 2026: the tokenizer note and the Gemini 4 Argon price change.
- All project numbers: the projects’ own config files, commit messages and measured runs, 2026.