Skip to content
AI-Native PM

The bill of materials: cost the task, not the call

Chapter 2 of 8 in The Unit Economics of AI · 16 min

Your team runs a cost sprint and hits its goal: you trim the system prompt, move the first pass to a smaller model, and cut the cost per API call by a third, and you lead the next review with that win. Then the invoice for the following month comes in higher than the one before it. The same rewrite that made each call cheaper also changed the sequence of calls the feature makes. A task that used to finish in two calls now takes a planning call, a drafting call and a judge pass (a call to a second model that checks the draft), and when the judge fails the draft, the drafting call and the judge pass run again. Finishing one user task now takes five calls, plus two retries on a bad run. Each call costs less than before, but each task costs more, and the team's dashboard counted only calls.

Count successful tasks, not API calls

In Why good AI features die of bad unit economics, features failed because the cost of serving each user climbed while the revenue from each user stayed flat. To fix that, start by measuring the right unit, which is cost per successful task: everything you spend, divided by the number of tasks users actually completed. A task is the thing the user came to do: an email drafted and sent, a support question resolved, a meeting turned into a summary the user accepted. A call is one request to the model, a piece of plumbing the task happens to use, and the number of calls changes every time engineering changes the sequence of calls, which is exactly what happened in the opening scene.

Measure cost per successful task, not per API call, and count the cost of failed attempts, retries and judge passes in the total you divide by the number of completed tasks.

The word successful matters in that definition. Think of a task the user abandoned halfway, an answer the user rejected, or a draft that failed the judge three times before the user gave up. You paid for the tokens in all of them, and none of them produced anything a customer paid for. So all of that spending counts in the total, while only completed tasks count in the number you divide by. This changes the result a lot: if one task in five fails, each of the four that finish carries a share of the failed task's cost on top of its own. That means a team can leave its prompts untouched and still cut its cost per task just by raising the share of tasks that users complete.

The bill of materials for one task

To cost a task, you list everything you spent between the moment the user starts it and the moment they get what they came for. We call that list the task's bill of materials, or its receipt for short, and it has more lines than you might expect.

The diagram, titled TASK BILL OF MATERIALS, shows one task's receipt. The faded receipts behind it are failed attempts, and their cost goes on the same receipt as the task that finally succeeded. These are the lines a full receipt needs:

  • Input tokens. Everything the model is given: the system prompt, the instructions, the retrieved facts and the conversation history, billed again on every call. On a task that takes five calls, you pay to send much of the same context five times.
  • Output tokens. Everything the model produces, including intermediate drafts and tool arguments (the inputs the model writes for a tool to use) that the user never sees. Providers bill output at a multiple of the input rate, so long intermediate steps cost more per token than anything the model was given.
  • Tool calls. Every lookup the product makes in the middle of a task adds a round trip, and the results go into the context window (the space that holds everything the model is given on one call) as input tokens on the next call. External search and data APIs can also charge their own fee per request.
  • Retries and failed attempts. A malformed response, a timeout, a draft the judge fails: the provider bills each one in full and you get nothing back for it, so retries are pure cost with no revenue.
  • Evaluation overhead. You pay for judge passes on live traffic and for the sample of outputs you grade for quality, and both belong on the receipt of the tasks they check. We set up this checking in Graders: deterministic, judges, and humans.
  • The heavy-user tail. When you average receipts, you lose sight of the users at the far end of the usage curve, who attach long documents and have long conversation histories. Their tasks can cost a large multiple of the median task, and on many products a small group of users accounts for most of the spend.

If you leave a line out, your per-task figure comes out lower than the real cost, and the difference shows up as bad news on every invoice.

What to ask engineering to log

You do not need to build any of this yourself, but you do need to ask engineering for each of these by name, because the default dashboards do not show them.

  • Per-task token logs. Every model call is tagged with the task it was part of and records its input and output token counts, so you can add up what a task cost instead of guessing.
  • A task-completion marker. An event your product logs when the user gets what they came for: the email sent, the ticket closed, the summary accepted. Without it you have no count of completed tasks to divide by, so you cannot compute cost per task at all. The same marker is also an input to the live quality tracking from Production signals: evals after the ship.
  • Retry counts. How many attempts each task took, and why each failed attempt failed, since every retry is a full-price call that produced nothing.

If your team's dashboard shows calls and not tasks, it will overstate your savings whenever a change adds calls, because each call then looks cheaper while the task as a whole gets more expensive.

Where most of the money goes: re-sent context and retries

When a team writes its first complete receipt, it usually expects output tokens to be the biggest cost, because the output is the part everyone looks at. The receipt almost always shows something else. On features that make several calls per task, input tokens are the biggest cost: the history that is re-sent on every call, retrieved documents pasted in whole when one paragraph would have done, and a system prompt that has collected so many additions that it is far longer than the user's question. Retries make this worse, because a retry re-sends the whole context, with everything packed into it, and the provider bills all of it again, not just the answer that came back wrong.

On features that make several calls per task, most of what you spend goes to the context you re-send on every call and to retries, not to the answer at the end.

This is why the cost work with the biggest savings is often work on context. In Context budgets: fit the right facts into a finite window you decided what actually belongs in the context window on each call, and how much of it, and the receipt shows you whether those decisions are saving money. The per-token rates change too often to print here, so our dated Price Sheet keeps the current numbers. The pattern that stays the same is that a provider's flagship model (its top model) costs a large multiple of what its small models cost, and output costs more than input.

Try it now

In this drill you write your first real receipt, and you will use it again in Write your Inference Budget and ship a feature that pays for itself at the end of this part.

Get your task. Pick one real workflow with an unambiguous finish line: a task in your own product if you can read its logs, or a task you personally run with an assistant, like turning meeting notes into a document you actually send.

Log every call it takes. Run the task end to end and record each model call it makes, with input and output token counts from your provider's usage dashboard, and mark which calls were retries or checks rather than first attempts. Scale it down: one task, hand-counted straight from the usage dashboard, is enough to learn the method.

Write the receipt. On one page, total the tokens in, the tokens out, the tool calls, the retries, and any judge passes, then compute the per-task cost at your provider's current rates, which live on their pricing page and in the Price Sheet.

Find where the money went. Circle the largest line. If it is input tokens, write one sentence on what filled the context window and whether the task needed it; if it is retries, write one sentence on why the failed attempts failed. That sentence tells you where to cut first.

Chapter Summary

  • Measure cost per successful task: everything you spend, divided by the tasks users actually completed.
  • A task is what the user came to do. Calls are plumbing, and the number of calls changes every time engineering changes the sequence of calls.
  • You pay for failed attempts, retries and judge passes even though they finish nothing, so they go on the same receipt as the tasks that succeed.
  • The full bill of materials covers input tokens, output tokens, tool calls, retries, evaluation overhead and the heavy-user tail.
  • Ask engineering by name for per-task token logs, a task-completion marker and retry counts.
  • A dashboard that shows calls instead of tasks can show a saving while each task costs more, and the team finds out when the next invoice arrives.
  • On features that make several calls per task, most of the money usually goes to the context you re-send on every call and to retries, not to the answer at the end.
  • Rates change often, so they are kept in the dated Price Sheet, and the chapters use ratios that stay true as prices change.
  • Cost is one side of the budget. The other is how long the user is willing to wait, which is the subject of Latency: design how fast it feels.

Sources

  • Huyen, C. (2025). AI Engineering: Building Applications with Foundation Models. O'Reilly Media.
  • OpenAI and Anthropic usage dashboard and pricing documentation (last verified July 2026).
  • The dated Price Sheet for current per-token rates and model-tier ratios.