Learn · Cost

What does your agent cost per task?

A monthly model bill tells you what you spent, not what you got for it. This guide covers the unit costs worth tracking, the pricing mistakes that make them wrong, and the controls that keep cost from drifting between releases.

An AI agent's cost is its token usage multiplied by a price for each model it calls, and the number worth managing is cost per successful task, not the monthly total. Controlling it takes five measurements: a unit cost per task, the spend that came after a session had already failed, what evaluation itself costs, a cost rule in the release gate, and alerts that fire before the invoice does.

Total spend is the wrong number

A monthly total says what the bill was. It does not say which agent drove it, whether the work was worth it, or what one finished task cost. Unit costs do, and there are three worth keeping.

UnitHow it is computedWhat it tells you
Cost per turnModel spend divided by conversation turnsHow expensive a single exchange is
Cost per taskModel spend divided by the tasks handledWhat one piece of work costs, finished or not
Cost per successful taskAll model spend on the window's tasks divided by the tasks that succeededWhat a result costs

The third is the one to manage. Failed tasks stay in the numerator, because they are what make success expensive. The gap between cost per task and cost per successful task is what failure costs you in model spend alone. If no task succeeded, the figure is unknown, not zero.

A task here is one unit of work, however many model calls it took: the same unit a business KPI is counted in.

How cost is computed, and where it goes wrong

The arithmetic is simple: the token counts from each model call, multiplied by a price for that model. The traps are all in the price.

TrapWhat goes wrongThe rule
A model with no known priceIt is counted as free, or given a guessed rateLeave it unpriced. Count its tokens, mark the total partial, and read a partial total as a floor
List price when you pay a negotiated rateEvery figure is overstatedRecord your own rate per model, and let it win over the list price
A self-hosted modelTokens are not what you pay forSet zero on purpose. Zero is a price you chose, not a blank
Cached inputCached tokens are billed at the full rate, or droppedPrice the cached share at the cached rate. If you do not know it, bill at the input rate, a safe over-estimate
A price changeLast quarter's spend is silently rewrittenGive every price an effective date. A run is costed at the price in force when it ran
Cost stored when the trace is writtenA wrong price is baked into historyCompute cost from tokens when the number is read, so a corrected price corrects every figure it applies to

A visibly missing figure is better than a confidently wrong one. Know, too, what the number leaves out. Token pricing covers model calls. A tool call that uses no tokens adds nothing to it, so fees for outside services need a line of their own.

Wasted spend: what failure costs

Wasted spend is what an agent spent after a session had already gone wrong. In a session that failed, find the first failing step and add up the cost of that step and every step after it. Everything before it was the agent doing useful work. Everything from it onward bought nothing.

An example: an agent looks up an order, calls an inventory tool that times out, calls it again, and answers anyway with a guess. The lookup was useful. The timed-out call, the retry and the answer are waste.

Four changes reduce it: fail fast when a dependency is down, retry with backoff and then stop, use a fallback, and move the check that catches the failure earlier in the flow. Stopping sooner reduces waste. Fixing the step that breaks removes it.

What evaluation itself costs

Evaluation is a second bill, and it is easy to miss because the judges spend it, not the agent. Every run an LLM judge grades is at least one more model call, and a composite judge makes one per component.

  1. Sample. Scoring a representative share of live traffic measures quality without paying to grade every run.
  2. Cap it per day. A percentage alone is not safe when traffic spikes. A daily ceiling on the runs each judge may score turns a surprise into a known maximum.
  3. Use code where code will do. A check for a missing tool call or a malformed response needs no model and uses no tokens.
  4. Choose the judge model on evidence. The judge model is not the agent model, and a cheaper judge changes the evaluation bill without touching the agent. Switch only after the cheaper judge is tested against your reviewers' labels. LLM-as-a-judge covers that test.
  5. Do not grade twice. When you compare judge models, reuse the scores that already exist.

Report the two bills separately. A low judge cost beside a high estimate for full coverage only means the judges are sampling, which is the point.

A cost rule in the release gate

A cost regression is a regression. A prompt that doubles in length or an extra model call in the flow can pass every quality check and still raise the bill, so the release gate is the place to catch it. A cost rule takes one of three shapes.

RuleFails the build whenUse it for
A ceilingAverage cost per case is above the budget you setHolding an agent to a unit cost
An increase limitCost per case rises more than a set amount, or a set percentage, over the current versionCatching drift release by release
A required savingThe candidate is not at least a set percentage cheaperA change whose purpose is to cost less

Pair the cost rule with a quality rule in the same policy, so the gate reads "cheaper and still hits the number" and never one without the other. Decide per rule whether a breach blocks the build or only warns. Latency can be held to a ceiling and an increase limit in the same way.

One case needs care. When a run cannot be priced, the rule is skipped and says so. Reading a missing cost as zero, and therefore as under budget, is the mistake the rule exists to prevent.

Alerts on spend

A gate catches what a release changes. An alert catches what traffic changes: a new customer, a loop, a provider swapping a model underneath you. Two kinds of rule cover most of it. A threshold rule names a metric, a comparison, a threshold and a window, and spend, tokens and cost per task all qualify. A trend rule fires when cost per task rises by a share you set, with no fixed figure to maintain.

Model choice is one lever

Everything above holds the model fixed. Changing it is often the largest lever and always the riskiest, because a cheaper model can lose quality exactly where it matters. The test is a controlled comparison: one frozen suite, the same judges, the same bar, every candidate repeated. Switching to a cheaper model without regressions covers it in full.

Sometimes the expensive model is the right one. The point of measuring is that you can show why.

Questions

How do I calculate what an AI agent costs?

Multiply the token counts from each model call by a price for that model, then divide by the unit you care about: turns, tasks, or tasks that succeeded. Use the rates you actually pay, give every price an effective date, and leave a model with no known price unpriced so the total is marked partial and not understated silently.

What is cost per successful task?

All model spend on the tasks in a window, divided by the tasks that succeeded. Failed tasks stay in the numerator because they are what make success expensive. The gap between cost per task and cost per successful task is what failure costs in model spend alone.

What is wasted spend?

What an agent spent after a session had already gone wrong: the cost of the first failing step and every step after it, in sessions that failed. Sessions that recovered are not counted. Summed per failure mode, it puts a cost on each failure and shows which fix removes the most waste.

How do I keep evaluation from becoming its own large bill?

Sample live traffic and do not grade every run, put a daily ceiling on the runs each judge may score, use code-based checks where no model is needed, and move to a cheaper judge model only after it is tested against your reviewers' labels. Report judge spend separately from agent spend.

Can a release be blocked on cost?

Yes. A release gate can carry a cost rule: a ceiling on average cost per case, a limit on the increase over the current version, or a required saving. Pair it with a quality rule so a build has to be both good enough and within budget. A run that cannot be priced is skipped, not passed.

What if I do not know a model's price?

Leave it unpriced. Count its tokens, show its cost as unknown, and label any total that includes it as partial, which makes that total a floor. A guessed rate produces a figure that looks exact and is wrong.

Do you trust your agents?

Bring one agent and the number it was funded to move. We review its failure modes together.

Request a briefing
You bring the traces. Neens finds what keeps failing.