AI API Cost Tracking
Your AI Agent Failed. Why Isn’t That Cost in Your Report?
Three tasks ran. Two passed. If you look at the two that passed, they cost $0.006 each. Put the failed task back on the bill and the cost per delivered result rises to $0.009.
3 min read - Published Nov 15, 2026 - Updated Nov 15, 2026
What the failed task cost
That’s 50% more in this example, with the same model and the same token prices. The difference is one task that ran twice and delivered nothing. If you’re using the lower number to set a budget, you’ve left out a cost your team still has to pay.
Here’s the sample trace. It’s a small synthetic example with five model calls across three tasks. Every call uses GPT‑5.4 mini at standard rates of $0.75 per million input tokens and $4.50 per million output tokens. Four calls each use 1,000 input tokens and 500 output tokens, at $0.003 per call. Task B's single fallback call uses 2,000 input tokens and 1,000 output tokens, at $0.006. The five calls add up to $0.018. OpenAI model pricing
| Task | What happened | Model cost |
|---|---|---|
| A | Succeeded on the second attempt | $0.006 |
| B | Succeeded on a call marked as a fallback | $0.006 |
| C | Failed after two attempts | $0.006 |
| Total | Two tasks succeeded | $0.018 |
The two successful tasks cost $0.012 between them. That’s where the $0.006 average comes from. To find out what each delivered result cost the team, divide all $0.018 by the two successes. Task C goes into the spend total even though it delivered zero results.
The report also shows $0.006 under Retry tax. Half of that came from the second attempt that saved Task A. The other half came from the second attempt on Task C, which still failed. That last $0.003 appears under both retry tax and Failed-work cost. It was paid once, so adding the two columns would count it twice.
You can check both numbers yourself. Open the report and select Load synthetic example. Look for $0.006 in failed-work cost and $0.009 per successful task. Replay the sample trace
Which retry would you cut?
A’s second attempt cost $0.003 and got the task over the line. C’s second attempt cost the same and got nowhere. If you only track the total spent on retries, those two calls look identical.
Start with the tasks that kept failing. Pick a few and look at what changed between attempts. If the same required field was missing both times, another call may just buy you the same error. If the first call timed out and the next one finished the job, that retry may be worth keeping.
If you change the retry rule, compare the old and new versions on the same set of tasks. Check how many passed and what each success cost. A lower bill is easy to get when the agent gives up sooner. The saving you want is a lower cost for the work you still deliver.
How to calculate AI agent cost from your own traces
Start with one workflow and include its failed tasks. Keep each model call’s provider, model ID, input and output token counts, and the attempt it belongs to. Decide what counts as success before you pull the numbers. For an invoice extraction agent, that could mean the extracted fields passed validation and the invoice was accepted by the next system. An HTTP 200 only tells you the request got a response.
The report accepts Agent Cost Evidence JSON v0.1, or a supported OpenInference / OpenTelemetry OTLP JSON trace with a separate task outcomes file. The second file supplies the task and attempt mappings and records which tasks passed. Remove sensitive metadata before you import. The calculation runs in your browser using current verified standard rates, so the result is an estimate at today’s prices.
Before you spend a day testing a cheaper model, take one trace you already have and check what the tasks that never finished cost you. Check the cost of failed tasks in your trace
Run your own agent trace.
Drop in a trace with task outcomes and see what each successful task cost, failed work included. It runs in your browser.