AI unit economics: cost per task, not cost per token
· 8 minute read · Pivot-al
Most teams learn what their AI feature costs when the invoice arrives. The invoice is itemized by model and token count. It does not say which feature spent the money, which customers drove it, or whether the spend bought anything. Finance asks why the bill doubled, and the only answer engineering has is that usage went up.
The fix is to reason in your own unit instead of the supplier's. The provider sells tokens, and your customer buys tasks: a ticket resolved, a contract extracted, a question answered. The price per token is one input to the cost per task, and usually not the one that matters most.
Why the token price misleads
Cost per task looks roughly like this:
cost per task =
sum over every model call in the task of
(input tokens x input price + output tokens x output price)
+ embedding, reranking and tool costs
+ the cost of retries and failed attempts
The token price appears once. Everything else is a design decision: how many calls a task makes, how much context each call carries, which model each call goes to, and how often it retries. A model at half the price that needs twice the calls saves nothing. An agent loop that re-sends its whole growing history on every step has an input cost that grows roughly with the square of the number of steps, at any price.
In a representative, anonymized teardown of a Series-B B2B SaaS company, we found an internal assistant that re-embedded the full corpus per query and routed trivial lookups to a frontier model, roughly 30 times what a scoped design needs. Nothing on the invoice pointed at it. The cost came from how the assistant was designed, and no price on the list would have changed that.
Instrument at the task level
Give every task an ID
Generate a task ID at the entry point and pass it through every model call, embedding call, reranker call and tool call that the task triggers. If you already use a tracing system, a task is a trace and each call is a span.
Record usage and price it later
For each call, store what the provider reports, plus your own labels:
{
"task_id": "t_8f2c",
"task_type": "support_answer",
"tenant_id": "tenant_042",
"step": "generate",
"model": "large-model",
"model_version": "2026-09",
"input_tokens": 6000,
"cached_input_tokens": 2000,
"output_tokens": 500,
"attempt": 1,
"latency_ms": 2400,
"outcome": "ok"
}
Store token counts and the exact model version. Keep prices in a separate, versioned table and join at query time. Prices change and contracts get renegotiated, so you want to be able to recompute history, and to ask what last month would have cost under a different routing rule.
Roll it up three ways
- Per task type. Look at the median and the 95th percentile instead of the mean, because the tail is where runaway loops and oversized contexts live.
- Per customer. Usage is rarely even across accounts. If you charge a flat price, some accounts may cost more to serve than they pay. You cannot see that without a tenant ID on every record.
- Per successful task. Divide spend by the tasks that met the quality bar, not the tasks attempted. A failed task still costs money, and then a human usually does it again.
Add the costs that never show up as tokens: the vector database, any GPUs you host yourself, third-party APIs that tools call, and human review time.
Where the money usually goes
The same handful of patterns turn up in most systems we look at:
- Recomputing what does not change. Embedding documents at query time instead of once at ingestion. Re-summarizing the same file on every request.
- One model for everything. Classification, routing, short lookups and format conversion all sent to the largest model because that was the one wired in first.
- Unbounded context. The whole conversation history, every retrieved chunk and a system prompt that has only ever grown, sent on every call.
- Retries without a budget. A timeout or a failed parse triggers a full re-run. Nested retries in the client library, the orchestration layer and the job queue multiply each other.
- No caching. The same question, the same long instructions and the same retrieved documents paid for at full price each time.
- Unconstrained output. No length limit and no instruction to be brief. Output tokens typically cost more than input tokens.
The levers
Tiered model routing
Send each step to the smallest model that passes your evals for that step. A cheap classifier or a set of rules decides which tier a request needs, with escalation to the larger model when the small one reports low confidence or fails a check. Some steps should not go to a language model at all: a lookup by ID is a database query.
Prompt and retrieval caching
Most major providers offer some form of prompt caching, which bills a repeated prompt prefix at a reduced rate. To benefit, put the stable content first (instructions, tool definitions, fixed reference material) and the variable content last. On your own side, cache embeddings by content hash, cache retrieval results for repeated queries, and cache full responses where the same question legitimately gets the same answer. Scope every cache key by tenant and by permission, or you will serve one customer's answer to another.
Scoped retrieval
Filter by tenant, document type and date before the vector search, not after. Retrieve fewer chunks and rerank them. Smaller, better context is cheaper, and it often improves answer quality as well, because the model has less irrelevant text to be distracted by. The isolation side of this is covered in RAG tenant isolation.
Batching
Work that does not need an answer in seconds should not be paying for one. Several providers offer asynchronous batch interfaces at a lower price in exchange for slower turnaround. Nightly enrichment, backfills, bulk classification and evaluation runs are the usual candidates.
Output-length control
Set a maximum output length. Ask for structured output with only the fields you use. If the application needs a category and a confidence, do not pay for three paragraphs of explanation.
Budgets and limits
Cap steps per agent run, retries per call and spend per task. When a task hits the cap, fail it visibly and log it, so that you can see which tasks ran away and look into why.
A worked example
The numbers below are invented for the arithmetic. They are not any vendor's prices.
Assume a large model at $10 per million input tokens and $50 per million output tokens, and a small model at $1 and $5. A support assistant handles 100,000 tasks a month. One task in ten is retried once.
Before. Every task goes to the large model with 20,000 input tokens of context and 500 output tokens.
- Input: 20,000 x $10 per million = $0.20
- Output: 500 x $50 per million = $0.025
- With retries: $0.225 x 1.1 = about $0.25 per task
- Monthly: about $24,750
After. A router sends 60% of tasks to the small model with 4,000 input tokens and 300 output tokens. The other 40% go to the large model with 6,000 input tokens, of which a 2,000-token stable prefix is cached and billed at an assumed 10% of the normal rate.
- Small-model task: $0.004 + $0.0015 = $0.0055
- Large-model task: $0.002 cached input + $0.04 fresh input + $0.025 output = $0.067
- Blended: 0.6 x $0.0055 + 0.4 x $0.067 = about $0.030
- With retries: about $0.033 per task
- Monthly: about $3,300
That is roughly a sevenfold reduction with no change in the price list, and almost all of it comes from context size and routing. The number only means something if quality held, which the section on tying cost to quality covers.
Forecasting spend
Once you have cost per task, a forecast is multiplication:
monthly spend = active customers
x tasks per customer per month
x cost per task
Forecast each term separately, per task type. Three things routinely break a naive forecast:
- Cost per task drifts. Corpora grow, conversations get longer, and someone adds a step. Track the per-task figure weekly and alert on the trend, not only on the bill.
- The mix changes. A new feature or a large customer shifts traffic toward the expensive task type.
- The tail grows. Median cost stays flat while the 95th percentile climbs, which an average hides. Forecast from the distribution.
Then compare cost per task with revenue per task or per seat. That ratio is the unit economics, and it tells you whether growth improves your margin or erodes it.
Tie cost to quality
Every lever above can make the product worse. A smaller model misses harder cases, tighter retrieval can drop the one chunk that mattered, and a shorter output may leave out the caveat.
So no cost change ships on its own. Each one runs against a fixed eval set first, and you record both numbers: cost per task and pass rate. The metric to watch is cost per successful task. A change that cuts cost by half and drops the pass rate from 92% to 70% has moved the work to your support team.
If you do not have an eval set, build that before you optimize, because without one you cannot tell whether a cheaper configuration still does the job. Building an LLM evaluation harness covers how.
Where to start
Add a task ID and a tenant ID to every model call, store token counts by model version, and look at the 95th percentile by task type.
If the system is already in production and you want an outside measurement, our Production AI Audit reports cost per task alongside eval coverage and a red-team run. If you are still deciding what to build, the Proof Spike measures cost per task on your real data before you commit to the full build. For a quick second opinion, the Teardown Clinic is a free 30-minute session with a senior engineer.
