If you run AI agents in production, someone will eventually ask what they cost to operate, and "the OpenAI bill was $9,000" is not an answer to that question. It is a total with no denominator. The useful version is a unit cost, and for agents the right unit is the successful run. The reason is specific to how agents fail.
Why the average lies
A normal request either works or throws. An agent can do neither: it can retry, loop, partially complete, and produce nothing useful while still spending money on every model call along the way. Average cost over all runs quietly absorbs that waste. Picture an agent where most runs cost two cents, but one run in twenty falls into a retry loop and burns four dollars before giving up. The average looks fine. The truth is that one in twenty of your runs is a small fire, and the average is the thing hiding it.
Cost per successful run does not hide it. Divide total spend by the runs that finished cleanly, and the cost of every loop and failure is folded into the price of the successes they were trying to produce. Now the fire shows up as a number going the wrong way.
The three cuts that matter
Once you price per run, three attributions turn cost into a decision:
- Per agent. Which agent spends the most, ranked, over any window. This is where you find the one agent quietly costing more than the rest combined.
- Per customer. Tag the customer at run start and spend attributes retroactively. Now you can tell a cheap account from one you are losing money to serve, which is the difference between pricing that works and pricing that does not.
- Per feature. See which AI feature has poor margins before you ship it wider. A feature that delights users and loses money on every use is a problem you want to find in the dashboard, not the board deck.
None of these are visible in a provider console, because the console knows API keys, not agents, customers or features.
Priced where it cannot lie
One implementation detail decides whether the numbers are trustworthy: price on the server, not the client. The SDK should send tokens and the model, and the cost should be computed server-side from a maintained rate card, cache aware, so prompt-cache reads are not counted as fresh input. A client-side cost estimate drifts from the invoice the moment a price changes or a cache hit lands. A server-side price, cache aware, lines up with what you actually pay.
What to watch
Three signals, and they compound:
- Cost per successful run, per agent, over time. A prompt change that adds tokens shows up as a step change on the day it ships.
- Failed and retried run cost. The money spent on runs that produced nothing, surfaced rather than averaged away.
- An anomaly alert on the per-agent baseline, so a runaway agent pages you before the invoice does, not after.
Get those three and AI cost stops being a mystery line item and becomes a unit economic you can manage like any other.
AgentPing prices every run server-side, cache aware, and rolls cost up per agent, customer and feature, with cost-per-successful-run as the headline and anomaly alerts on each agent's baseline. See Spend, or get started free.