# What an AI agent really costs: cost per completed task

> Price per token says little about what an agent costs. What benchmarks and vendor documentation show about calls, tokens, reasoning and failed attempts, why a cheaper model can cost more per task, and how to estimate it for your own agent.

- URL: https://bardak.ai/posts/ai-agent-cost-per-task
- Author: Ivan Bardak (https://bardak.ai/pages/about)
- Published: 2026-11-03
- Updated: 2026-11-16

Most agent proposals I review estimate cost the same way: the price per million tokens, multiplied by a guess at how many tokens a request uses. The result is usually wrong by an order of magnitude, sometimes in each direction for different parts of the same system.

An agent is not a chat request. It calls the model many times per task, carries tool definitions and earlier steps in every call, thinks in tokens you pay for but never see, and sometimes fails after spending the money. This post builds the cost of an agent from what public benchmarks and vendor documentation actually show, and ends with a way to estimate it for your own system.

**The short answer:** measure cost per completed task, not cost per token. It is the cost of one attempt, calls times tokens times price, divided by the share of attempts that succeed. On the same coding benchmark and the same agent setup, that number ranges from about six cents to about seven dollars depending on the model, and a model that is cheaper per token can be dearer per task. Caching, batching and fewer tools cut the bill far more than haggling over list prices.

## The formula

Three numbers decide what an agent costs:

1. **Calls per task.** An agent plans, calls a tool, reads the result and calls the model again. Coding agents on SWE-bench made from about 15 to almost 90 model calls per task, depending on the model.
2. **Tokens per call.** Every call carries the instructions, the tool definitions, the conversation so far and the retrieved context, plus the output, including reasoning tokens that are billed but not shown.
3. **Success rate.** Failed attempts cost money too, and they tend to be the expensive ones.

Put together: cost per completed task equals calls per task, times the token cost of one call, divided by the success rate. The last part is the one most estimates leave out. In the SWE-agent study, successful runs had a median cost of $1.21 and 12 steps, while unsuccessful runs averaged $2.52 and 21 steps: agents succeed quickly and fail slowly ([Yang et al. 2024](https://arxiv.org/abs/2405.15793)).

## Same benchmark, very different bills

The SWE-bench leaderboard runs every model in the same simple agent, mini-SWE-agent, on the same 500 real software issues, and publishes the cost ([SWE-bench](https://www.swebench.com/)). That makes it a rare like-for-like comparison:

**SWE-bench Verified with the same agent: cost per resolved issue**

| Model | Resolved | Calls per issue | $ per attempt | $ per resolved issue |
| --- | --- | --- | --- | --- |
| GPT-5 mini (medium) | 59.8% | 14.5 | 0.035 | 0.059 |
| MiniMax M2.5 (high) | 75.8% | 60.5 | 0.073 | 0.097 |
| Gemini 3 Flash (high) | 75.8% | 56.1 | 0.356 | 0.47 |
| DeepSeek V3.2 (high) | 70.0% | 88.5 | 0.448 | 0.64 |
| Claude 4.5 Opus (high) | 76.8% | 32.9 | 0.754 | 0.98 |
| GPT-4.1 | 39.6% | 19.5 | 0.146 | 0.37 |
| GPT-4.1 mini | 23.9% | 89.2 | 0.435 | 1.82 |
| GPT-4o | 21.6% | 63.1 | 1.531 | 7.08 |

Cost per resolved issue is my arithmetic: cost per attempt divided by the share resolved. Runs from July 2025 to February 2026, so older models had older prices. Source: SWE-bench leaderboard, Bash Only (mini-SWE-agent), as of October 2026. Data: https://bardak.ai/data/ai-agent-cost-per-task/swe-bench-verified-with-the-same-agent-cost-per-resolved-issue.csv

Two things stand out. The spread is more than a hundredfold for the same tasks. And per-token price misleads: GPT-4.1 mini is cheaper per token than GPT-4.1, but it made about 89 calls per issue against about 20 and solved fewer, so each resolved issue cost five times as much. Researchers at Princeton found the same pattern across agent benchmarks: for similar accuracy, cost can differ by almost two orders of magnitude ([Kapoor et al. 2024](https://arxiv.org/abs/2407.01502)).

## Realistic work costs more

Coding issues are short, well-defined tasks. In TheAgentCompany, a simulated software company with 175 tasks across engineering, finance and HR, agents take more steps and fail more often ([Xu et al.](https://arxiv.org/abs/2412.14161); [leaderboard](https://the-agent-company.com/)):

**TheAgentCompany: cost per fully completed task**

| agent | Cost per completed task |
| --- | --- |
| OpenHands + Claude 3.5 Sonnet | 26.42 |
| OpenHands + Claude 3.7 Sonnet | 15.41 |
| OpenHands + GPT-4o | 15.00 |
| OpenHands + Gemini 2.5 Pro | 13.97 |
| OpenHands-Versa + Claude Sonnet 4 | 4.92 |

My arithmetic: the published cost per attempt divided by the share of tasks fully completed (24% to 33%). The benchmark assumes no prompt caching, so real bills would be lower. Source: TheAgentCompany paper (December 2024) and leaderboard (checked entries, standard environment). Data: https://bardak.ai/data/ai-agent-cost-per-task/theagentcompany-cost-per-fully-completed-task.csv

A cost per attempt of $1.29 to $6.34 becomes $5 to $26 per completed task. For an agent that replaces a few minutes of a person's time, those numbers do not work; for one that handles a task worth hundreds of dollars, they might. That comparison, value per task against cost per completed task, is the business case.

## Where the tokens go

- **Agents use several times the tokens of chat.** Anthropic reports that in its data agents use about four times more tokens than chat interactions, and multi-agent systems about fifteen times more ([Anthropic, June 2025](https://www.anthropic.com/engineering/multi-agent-research-system)).
- **Tool definitions ride along in every call.** A common five-server setup puts about 55,000 tokens of tool definitions into context, and even a single built-in tool adds hundreds of tokens ([Anthropic pricing](https://platform.claude.com/docs/en/about-claude/pricing)). See [MCP tool design](https://bardak.ai/posts/mcp-tool-design) for how to keep the list short.
- **Reasoning is billed as output.** OpenAI, Anthropic and Google all bill thinking tokens as output tokens, and OpenAI notes a model may generate from a few hundred to tens of thousands of them per request ([OpenAI](https://developers.openai.com/api/docs/guides/reasoning)). Output tokens cost four to five times as much as input tokens at all three.
- **Retries multiply everything.** Reliability benchmarks show the same agent failing some tasks on some tries and not others; every retry pays the full cost again. The latest numbers are in [AI agent reliability benchmarks, tracked](https://bardak.ai/posts/ai-agent-reliability-benchmarks).

Artificial Analysis shows how far list prices and real costs drift apart. It runs the same set of evaluations on every model and publishes what it cost ([Artificial Analysis](https://artificialanalysis.ai/models)):

**List price against real cost on the same evaluations**

| Model | In $/1M | Out $/1M | Index score | $ per task |
| --- | --- | --- | --- | --- |
| Claude Opus 5.5 | 4.00 | 20.00 | 58 | 10.04 |
| GPT-6.1 Sol | 2.00 | 10.00 | 55 | 1.27 |
| Claude Sonnet 5.5 | 2.00 | 10.00 | 54 | 10.02 |
| Gemini 4 Argon | 4.00 | 20.00 | 50 | 7.68 |
| Claude Haiku 5.5 | 0.10 | 0.50 | 36 | 0.41 |
| GPT-6 Luna | 0.10 | 0.50 | 28 | 0.15 |

Two models with the same $2 and $10 list prices cost $1.27 and $10.02 per task, because they use very different numbers of tokens on the same tasks, and the cheaper one scores higher. Sonnet costs as much per task as Opus at half the price per token. Each model at its highest reasoning setting on Artificial Analysis (High for Gemini 4 Argon), which prices Gemini 4 Argon at its standard $4 and $20 rather than the promotional $2 and $10. Source: Artificial Analysis, Intelligence Index v5.0, model pages, accessed 29 October 2026. Data: https://bardak.ai/data/ai-agent-cost-per-task/list-price-against-real-cost-on-the-same-evaluations.csv

## What cuts the bill

- **Prompt caching.** [Most of an agent's input repeats from call to call](https://bardak.ai/posts/prompt-caching-batching-routing). Anthropic charges cache reads at a tenth of the input price or less and says caching pays off after a single read ([Anthropic](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)); OpenAI caches automatically and discounts cached input by up to 95% ([OpenAI](https://developers.openai.com/api/docs/guides/prompt-caching)). Keep the stable part of the prompt, instructions and tool definitions, at the start so it can be cached.
- **Batch processing.** Anthropic, OpenAI and Google all halve the price for work that can wait up to 24 hours: overnight evaluations, document processing, re-indexing.
- **Fewer tokens through tools.** In Anthropic's example, letting the agent call tools from code instead of loading every definition cut one workflow from 150,000 tokens to 2,000 ([Anthropic, November 2025](https://www.anthropic.com/engineering/code-execution-with-mcp)). Fewer, better tools have the same effect.
- **Routing.** Send each step to the cheapest model that succeeds on it, measured on your own tasks, not on list price.
- **Limits.** Cap steps and spend per task. Since failures run longer, a cap mostly cuts the cost of attempts that would have failed anyway.

## A worked example

Take an agent that makes 20 calls per task, with 10,000 input tokens and 1,000 output tokens per call (reasoning included), on a model priced at $2 and $10 per million, and a 60% success rate on your evaluation set. My arithmetic:

**One agent, three ways to run it**

| Setup | Cost per attempt | Success rate | Cost per completed task |
| --- | --- | --- | --- |
| No caching | $0.60 | 60% | $1.00 |
| 70% of input read from cache at a twentieth of the price | $0.33 | 60% | $0.56 |
| Same, run as a batch at half price | $0.17 | 60% | $0.28 |

At 10,000 tasks a month, the difference between the first and last row is about $7,000 a month, before any change of model. Data: https://bardak.ai/data/ai-agent-cost-per-task/one-agent-three-ways-to-run-it.csv

Try it with your own numbers:

_An interactive agent cost calculator stands here on the web page at https://bardak.ai/posts/ai-agent-cost-per-task._

The same structure, with your own numbers, is in the [AI business case template](https://bardak.ai/downloads/ai-business-case-template.xlsx), next to a value range and a break-even success rate. The method behind it is in [A GraphRAG business case, done the evidence-based way](https://bardak.ai/posts/graphrag-business-case), and the retrieval side of the bill in [The real cost of GraphRAG](https://bardak.ai/posts/graphrag-cost).

## How to estimate the cost of your agent

1. **Build 30 to 100 real tasks** and run each several times with logging on.
2. **Record per task:** calls, input, cached input, output and reasoning tokens, and whether it succeeded.
3. **Compute cost per completed task,** not per call, at [current list prices](https://bardak.ai/posts/llm-api-prices) with caching and batching applied.
4. **Compare two or three models** on that number, not on price per token.
5. **Set a step and spend cap,** and check what it does to the success rate.
6. **Put the result next to the value of one task.** If cost per completed task is not well below it, change the design before scaling.

## How much weight this evidence deserves

**Appraising the evidence**

| Evidence | Strength | Main limitation |
| --- | --- | --- |
| SWE-bench and TheAgentCompany costs | Same tasks and setup for every model | Benchmarks, not your workload; costs at the prices of the run date; TheAgentCompany assumes no caching |
| Vendor pricing and caching documentation | Authoritative for prices and discounts | Prices change, some are promotional; tokenizers differ, so per-token prices do not compare exactly |
| Vendor engineering posts (Anthropic) | Real systems at scale | Written about their own products |
| Artificial Analysis | Independent, same evaluations for all models | Its evaluation mix, not your tasks |
| My cost tables | Transparent arithmetic | Illustrative numbers |

Data: https://bardak.ai/data/ai-agent-cost-per-task/appraising-the-evidence.csv

Cost is one of five things that decide whether an agent reaches production; the others are covered in [Agentic AI from demo to production](https://bardak.ai/posts/agentic-ai-from-demo-to-production).

## Sources

- [SWE-bench leaderboard, Bash Only (mini-SWE-agent).](https://www.swebench.com/)
- [Xu et al. (2024, revised 2025). TheAgentCompany: Benchmarking LLM Agents on Consequential Real World Tasks. arXiv:2412.14161.](https://arxiv.org/abs/2412.14161)
- [TheAgentCompany leaderboard.](https://the-agent-company.com/)
- [Yang et al. (2024). SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering. arXiv:2405.15793.](https://arxiv.org/abs/2405.15793)
- [Kapoor et al. (2024). AI Agents That Matter. arXiv:2407.01502.](https://arxiv.org/abs/2407.01502)
- [Anthropic (June 2025). How we built our multi-agent research system.](https://www.anthropic.com/engineering/multi-agent-research-system)
- [Anthropic (November 2025). Code execution with MCP.](https://www.anthropic.com/engineering/code-execution-with-mcp)
- [Anthropic. Pricing.](https://platform.claude.com/docs/en/about-claude/pricing)
- [Anthropic. Prompt caching.](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)
- [OpenAI. API pricing.](https://developers.openai.com/api/docs/pricing)
- [OpenAI. Prompt caching.](https://developers.openai.com/api/docs/guides/prompt-caching)
- [OpenAI. Reasoning models.](https://developers.openai.com/api/docs/guides/reasoning)
- [Google. Gemini API pricing.](https://ai.google.dev/gemini-api/docs/pricing)
- [Artificial Analysis. AI model comparison.](https://artificialanalysis.ai/models)
