How to Calculate AI Agent Cost Per Task Before It Wrecks Your Margin Founders pricing AI agents off a single clean API call underestimate real cost per task, which must include input and output tokens, every tool call, every retry, divided by task success rate, according to a Startup Fortune analysis. Using Anthropic's published Claude Opus 4.5 pricing of $5 per million input tokens and $25 per million output tokens as of its November 2025 release, a support agent reading a 2,000-token ticket plus 3,000 tokens of context and writing a 400-token response costs about $0.035 per attempt before tool calls and retries are counted. At an 85% first-attempt success rate the agent needs roughly 1.18 attempts per completed task, and at 70% success the compounding retries push a profitable-looking credit into negative margin. Founders price AI agents off a rough inference guess, not the real cost per task, and that gap between guess and reality is where margin quietly disappears. - How to calculate AI agent cost per task starts with tokens and tool calls, but retries are the term founders skip, and skipping it is what turns a profitable-looking credit into a negative-margin one. - Founders price AI agents off a rough inference guess, not the real cost per task, and that gap between guess and reality is where margin quietly disappears. - A SaaS seat costs you almost nothing per use. - An agent costs you money every single time it runs, and the amount varies wildly depending on how many times it fails before it succeeds. You don't price an AI agent the way you price a SaaS seat. A SaaS seat costs you almost nothing per use. An agent costs you money every single time it runs, and the amount varies wildly depending on how many times it fails before it succeeds. That's the part most founders get wrong when they set up an uptime credit or usage allowance: they size it off a single clean API call, not off what actually happens when the agent hits a bad day. Here's the real formula. Cost per task equals input tokens plus output tokens, multiplied by their respective per-token rates, plus the cost of every tool call the agent makes along the way, plus the cost of every retry needed to get to a successful completion, divided by your task success rate. Skip any one of those four terms and your estimate is fiction. Anthropic's published API pricing for Claude Opus 4.5 is $5 per million input tokens and $25 per million output tokens as of its November 2025 release. A customer support agent that reads a 2,000-token ticket, pulls in 3,000 tokens of account history and context, and writes a 400-token response is spending roughly 5,000 input tokens and 400 output tokens per attempt. That's about $0.035 per attempt. Founders stop there. That's the mistake. How Context Window Length Actually Breaks Your AI Agent's Unit Economics https://startupfortune.com/how-context-window-length-actually-breaks-your-ai-agents-unit-economics/ How does context window length affect inference cost? Not linearly. Attention scales roughly with the square of context length, and the KV cache adds a growing memory tax on top, which is exactly where AI agent unit economics quietly fall apart. - how context window size affects AI agent costs https://startupfortune.com/how-context-window-length-actually-breaks-your-ai-agents-unit-economics/ - why large language model context breaks unit economics https://startupfortune.com/how-context-window-length-actually-breaks-your-ai-agents-unit-economics/ Agents call tools. A support agent that queries a CRM, checks an order status API, and searches a knowledge base before answering isn't making one model call, it's making one model call plus three tool calls, and then a second model call to synthesize the tool results into a final answer. If your agent's loop averages two model calls and three tool calls per task, and each tool call carries its own latency and sometimes its own metered cost Algolia, Pinecone, and most vector databases bill per query , the token cost you calculated is maybe half of what the task actually costs you. Retries are where margin actually dies This is the term founders skip entirely, and it's the one that matters most. No agent succeeds on the first try every time. Some fraction of tasks fail, either because the model made a mistake, a tool call timed out, or the output didn't pass your validation layer, and your system retries. Say your agent has an 85% first-attempt success rate. That means 15% of tasks need a second attempt, and if your retry policy allows a second retry, some fraction of that 15% needs a third. The math compounds fast. At 85% success per attempt, you need an average of roughly 1.18 attempts to get one completed task 1 divided by 0.85 . At 70% success per attempt, which is common for agents doing multi-step reasoning over messy real-world data, you need roughly 1.43 attempts per completed task. Drop to 50%, which happens more than vendors like to admit on tasks involving ambiguous user intent or incomplete data, and you need 2 attempts per completed task on average. Run the numbers on our support agent example. At $0.035 per attempt in tokens alone, plus say $0.02 in tool call costs, your per-attempt cost is $0.055. At 85% success, your per-completed-task cost is about $0.065. At 50% success, it's $0.11, nearly double. If you priced your uptime credit assuming 85% and your actual production success rate lands at 60%, you've silently eaten a third of your margin on every single customer, and you won't see it until the month-end bill from Anthropic or OpenAI lands and doesn't match what you expected. Why a flat per-seat credit breaks on real usage This is the practical failure mode. A startup sets an uptime credit of, say, 500 agent tasks per month included in a $99 plan, priced off an assumed $0.06 per task. That's $30 of inference budget against $99 of revenue, which looks like healthy margin on a spreadsheet. But the assumption baked into that $0.06 number is a success rate and a tool-call pattern that held during testing on clean, curated data. Production data is not clean. A customer with messy CRM records, multi-language tickets, or longer conversation histories pushes both token counts and retry rates up simultaneously, and those two effects multiply rather than add. Replit ran into a public version of this dynamic with its Agent product's usage-based pricing in 2025, when users reported wildly variable per-task costs because agent runs that required more exploration, more file edits, and more build-and-check cycles consumed far more compute than simple one-shot code generation, even though both were nominally "one task." The company had to clarify and later adjust how it metered and communicated usage because a single flat per-task assumption didn't hold across the range of what users actually asked the agent to do. The lesson generalizes: if your agent's task complexity varies at all, a single average cost-per-task number will be wrong for a meaningful share of your customer base, and it will usually be wrong in the direction that costs you money, because the complex, expensive tasks are the ones most likely to need retries. Building the credit so it doesn't bankrupt you Calculate cost per task using your actual production logs, not your test environment. Pull 30 days of real agent runs, bucket them by task type if your product has more than one, and compute actual tokens consumed, actual tool calls made, and actual success rate per bucket, including every retry. Multiply that real average by 1.3 to 1.5 as a buffer for the tail. The tail is what kills you: a small share of tasks that spiral into five or six retries because the model gets stuck in a loop, and those outliers pull your true average well above your median. Why Does My AI Coding Agent Bill Keep Increasing Overnight https://startupfortune.com/why-does-my-ai-coding-agent-bill-keep-increasing-overnight/ Why does my AI coding agent bill keep increasing when nobody touched the keyboard overnight? Usually it's a runaway tool-call loop compounding token costs with every retry. This guide walks through the mechanism, a real incident involving Replit's agent, and the specific guardrails that stop it. - why AI coding agent bills spike overnight https://startupfortune.com/why-does-my-ai-coding-agent-bill-keep-increasing-overnight/ - preventing runaway tool call loops in agents https://startupfortune.com/why-does-my-ai-coding-agent-bill-keep-increasing-overnight/ Price the included credit against that buffered number, not the clean-case number. If your buffered real cost per task is $0.11, and you want a 70% gross margin on the inference-and-tools layer specifically, you need to charge roughly $0.37 per task equivalent inside your plan, or cap the included task count so the included compute never exceeds about 30% of plan revenue. Either framing works. What doesn't work is pricing off a number you calculated once, in testing, before you had production retry data. Re-run this calculation monthly for the first six months of any new agent feature. Success rates drift as you change prompts, swap models, or add new tools, and each change resets your retry math. A founder who prices once at launch and never revisits it is the one who discovers, three months and a thousand customers later, that the "included" tier has been running at negative margin the entire time. Also read: How to Build an AI Agent Usage Dashboard Customers Will Actually Trust https://startupfortune.com/how-to-build-an-ai-agent-usage-dashboard-customers-will-actually-trust/ • How to Structure AI Agent Pricing Finance Teams Can Actually Forecast https://startupfortune.com/how-to-structure-ai-agent-pricing-finance-teams-can-actually-forecast/ • How to Structure a Founder Non-Compete Before You Start Your Next Company https://startupfortune.com/how-to-structure-a-founder-non-compete-before-you-start-your-next-company/ This article is posted in AI News https://startupfortune.com/category/ai/ , check it out for more related stories. Join the discussion Open in the community → https://startupfortune.com/community/ Almost there. Sign in and your reply posts straight away.