AI in production
AI token cost: forecast LLM spend as usage grows
Tokens are the meter. The successful task is the unit you sell.
In brief
Measure AI token cost per feature, per tenant and per successful task, not only per token. Then lower the cost of each task: do deterministic work in code, route simple calls to smaller models, cache the context that repeats, and cap usage by plan. Forecast monthly spend as active users times task frequency times cost per successful task, and review those unit economics against your pricing every month.
On this page
- 01What unit should we use to measure AI cost?
- 02How do we attribute cost to tenants and features?
- 03Which architecture choices cut inference cost the most?
- 04How do we forecast AI token cost as usage grows?
- 05How should pricing and usage limits protect margins?
- 06What we see in production
- Frequently asked questions
01What unit should we use to measure AI cost?
Your provider bills you in tokens. Your customers do not buy tokens. If you track only token spend, you see the bill grow but cannot tell which feature, customer or plan drives it, or whether the money produced anything useful. This is part of our larger guide, LLMOps for SaaS: keep AI features working in production.

We measure inference economics as cost per successful task:
Cost per successful task = all model spend for a feature (including retries, failed attempts, guardrail calls and evaluation runs) / tasks that met the acceptance bar
"Successful" has to be defined per feature first. For drafting, it might mean the user accepted the draft with light edits. For extraction, the fields passed validation. For an agent, the action was approved and completed without a human redoing it.
This unit changes decisions. A cheaper model that fails one task in three can cost more per successful task than a stronger model that rarely fails, because every failure is paid for and then paid for again.
Three views of the same data serve three readers:
- Cost per call is for engineers tuning prompts, context and model choice.
- Cost per successful task is for product leaders deciding whether a feature earns its place.
- Cost per tenant per month is for finance, set against what that tenant pays.
02How do we attribute cost to tenants and features?
Attribution has to happen at the moment of the call. A monthly provider invoice knows your API key, not your customers.
Every model call should pass through one internal gateway that writes a usage record with these fields:
- Tenant ID, user ID and user role
- Feature ID and the step within that feature
- Plan tier at the time of the call
- Model and provider
- Uncached input, cached input, cache write and output tokens
- Latency, retry count and the task outcome once it is known
With that record, cost per tenant and cost per feature become ordinary queries. Allocate shared costs, such as embedding a common knowledge base or nightly evaluations, by each tenant's share of usage, and keep them visible as their own line.
Two details matter for multi-tenant products. First, caching interacts with tenancy: Anthropic documents that caches are isolated between organizations and, on several platforms, by workspace as well. That means the way you separate tenants can change how often context is reused. OpenAI offers an optional cache key that helps with separate cache accounting. Second, the outcome field is the one teams skip, and it is the one that turns spend into cost per successful task. Join it from product events you already log, such as accepted, edited, approved or abandoned.
03Which architecture choices cut inference cost the most?
The biggest savings come from sending less work to the model, sending it to the right model, and not paying twice for the same context. The table ranks the levers in the order we would apply them in an established product, starting with the ones that remove work entirely.
- Baseline. Three calls on the mid-size model: extract, calculate, write. Cost per task: $0.096.
- Move the calculation into code. Two model calls remain. Cost per task: $0.064.
- Route extraction to the small model. Cost per task: about $0.034.
- Cache the 10,000 stable tokens, assuming 80 percent of calls hit the cache and the rest pay the write rate. Cost per task: about $0.019.
If 80 percent of tasks succeed, cost per successful task falls from $0.12 to about $0.023. These figures illustrate the arithmetic; they are not client results. Your numbers will differ, which is why you measure them.
| Rank | Lever | What changes | Where it fits best |
|---|---|---|---|
| 1 | Move deterministic work into code | Calculations, validation, lookups, formatting and business rules leave the model entirely | Any feature that mixes language with arithmetic or rules |
| 2 | Route by difficulty | Extraction, classification and routing go to a small model; only reasoning and writing go to a larger one | Multi-step features and agents |
| 3 | Cache the stable prefix | System instructions, schemas and shared reference text are billed at the cached rate on repeat calls | Long, repeated instructions and multi-turn sessions |
| 4 | Trim context | Retrieval returns fewer, better passages; conversation history is summarized | Retrieval and chat features |
| 5 | Batch what can wait | Offline jobs use asynchronous batch pricing | Nightly summaries, backfills, bulk classification |
| 6 | Cap output | Structured outputs and length limits stop long answers nobody reads | Drafting and explanation features |
| 7 | Self-host at steady volume | Pay for capacity instead of tokens | High, predictable volume or strict data boundaries |
Research supports lever 2. The FrugalGPT paper found that fees across popular model APIs can differ by two orders of magnitude. The RouteLLM paper reported routers that cut cost by more than two times in some benchmark cases without lowering response quality.
Provider documentation shows why levers 3 and 5 matter. Anthropic lists cache reads at 0.1 times the base input price on most models, and 0.05 times on its current Opus and Sonnet models. Five-minute cache writes cost 1.25 times base input. Its Batch API takes 50 percent off input and output tokens. OpenAI says cached input is discounted by up to 95 percent and that caching is on by default for supported models.
A worked example.
Take an illustrative feature that turns account data into a written summary. Prices are Anthropic list prices as published in October 2026. A mid-size model costs $2 per million input tokens and $10 per million output tokens. A small model costs $0.10 and $0.50 for prompts up to 100,000 tokens. Cache reads cost 0.05 times base input on this mid-size model and 0.1 times on the small one. Each call carries 12,000 input tokens (10,000 of them stable instructions and schema) and returns 800 output tokens.
04How do we forecast AI token cost as usage grows?
Forecast from product behavior, not from last month's invoice.

Monthly inference cost = Σ over features (active AI users × tasks per user per month × cost per successful task) × (1 + overhead)
Overhead covers evaluation runs, embeddings, background jobs and spikes. The example uses 15 percent; replace it with measured values after a few months.
- 01
List each AI feature separately.
A chat assistant and a nightly report generator grow on different curves.
- 02
Measure adoption.
Active AI users per feature, not total seats.
- 03
Measure task frequency.
Tasks per active user per month, by plan tier and tenant size. This driver moves fastest, especially when agents chain steps.
- 04
Measure cost per successful task
from the usage records above.
- 05
Build three scenarios.
Expected, high adoption and heavy usage. Agree which one finance budgets against.
- 06
Reforecast monthly
with actual values, and flag any feature whose cost per successful task moved past an agreed threshold.
Continuing the example: 15,000 active AI users running 40 tasks a month is 600,000 tasks. At the baseline $0.12 per successful task plus 15 percent overhead, that is $82,800 a month. With the four levers applied, at about $0.0234 per successful task, it is about $16,100.
Now grow usage over a year to 30,000 active users at 60 tasks each, or 1.8 million tasks a month. The baseline design reaches $248,400 a month. The optimized design reaches about $48,400. Growth multiplied both lines by three, but only one stays inside a margin plan. The architecture sets the slope of the cost curve; usage growth decides how far along it you travel.
05How should pricing and usage limits protect margins?
Once you know cost per successful task, you can price against it. In the example, a typical user at 40 tasks a month costs $4.80 on the baseline design and about $0.94 on the optimized one. A heavy user at 400 tasks a month costs $48 or about $9.37. Flat, unlimited access priced for the typical user is exposed to the heavy one.
Guardrails that protect margins without hurting the experience:
- Include an allowance in each plan that covers typical use with room to spare, sized from measured task frequency by tier.
- Price heavy use separately, through credits, a higher tier or a paid AI tier, so revenue rises with cost.
- Set per-tenant budgets with alerts at 50, 80 and 100 percent of allowance, visible to the account team.
- Degrade gracefully at the limit. Move the tenant to a smaller model, queue non-urgent work for batch, or confirm before long agent runs, instead of failing outright.
- Show usage in the product, so the conversation about upgrading starts from shared facts.
Review one short table per feature monthly: active users, tasks, success rate, cost per successful task, revenue and gross margin. If a feature's cost per task rises while its success rate falls, that is an engineering problem before it is a pricing problem.
For the full picture, see how much production AI costs in SaaS and how to reduce AI infrastructure cost in production.
06What we see in production
The most reliable cost reduction we know is to give the model less to do. Three builds show the pattern.
A consumer nutrition planning app. Users describe their goals in text or by voice and receive a personalized meal plan with calories and nutrients. We split the work into LangGraph nodes: one detected the input type, one extracted keywords into a structured schema, and one checked that the required profile details were present before any food search ran. Calories, ingredient weights and daily values were computed in code from external nutrition data. The model only rephrased the results as a structured table. Arithmetic in a model is slow, costly and hard to trust; in code it is exact and close to free.
A scored customer and prospect database. A B2B software company had the same account in its CRM, billing, product usage, call and firmographic systems with conflicting values. We built survivorship rules and clean master records first, used a language model only to fill and check attributes such as company size and practice area, and scored accounts from the company's own history. The model became one step in the pipeline, called where it adds judgment rather than everywhere.
A records platform for a public-sector archive. Staff needed traceable answers over large, sensitive bilingual records, extraction of people, places and acronyms, and writing tools that never alter names, dates or figures. The documents could not go to an outside AI service, so the data boundary decided the hosting model before cost did. We settled architecture ownership first, consolidated the backend on one framework, and chose a self-hosted OCR model after side-by-side tests, including on handwriting. Self-hosting shifts the cost question from tokens to capacity and utilization.
On an analytics sync we redesigned in a client's own Google Cloud project, the job stopped loading the full message history into memory on every run. It now starts from the latest timestamp the destination already holds and reads only newer rows, in batches.
One more lesson from Peret, a prediction market app we readied for beta: plan gating on the server, Stripe subscriptions and a refresh cadence set around the AI provider's rate limit were settled together. Per-tenant metering belongs in that same layer, built at the start, not added after the first surprising invoice.
Frequently asked questions
When do self-hosted models become cheaper than APIs?
When volume is high and steady enough to keep GPUs busy, or when data cannot leave your boundary anyway. Compare cost per successful task at realistic utilization, not GPU-hour price against token price. Self-hosting is an ongoing operating commitment: servers to run, a serving stack to keep current, model license terms to follow and monitoring someone has to own. Count that engineering time, and evaluate the open model on your own tasks, before declaring a saving.
How much does prompt caching save?
It depends on how much of each prompt is a stable prefix and how often it hits. Anthropic bills cache reads at 0.1 times base input on most models, and writes at 1.25 times for a five-minute lifetime or 2 times for one hour. OpenAI cites cached-input discounts of up to 95 percent, with a 1,024-token minimum on newer models, where cache writes cost 1.25 times the uncached rate by default. Put static instructions first and dynamic content last.
Should heavy users pay more for AI?
Yes, when your cost rises with their use. Bundle an allowance that covers typical behavior in each plan, then charge heavy users through credits, a higher tier or a paid AI tier. Base the allowance on measured tasks per user by tier, not on a guess, and review it every quarter as behavior changes.
How do we budget for model price changes?
Budget per successful task, not per vendor, and keep an evaluation set of your own cases so you can test a different model in days rather than months. Route calls through one gateway so switching models is a configuration change. Prices move fast: Epoch AI found that the price to reach a fixed level of benchmark performance fell by between 9 and 900 times per year, depending on the milestone. Forecast with a price band, and reforecast monthly.
How Datics helps
Datics specializes in Brownfield AI: production AI inside software people already rely on. Once your AI is live, AI Care re-tests it every month on your own cases and keeps it accurate and affordable, for $1,500 a month per capability. Not sure it is ready? The AI Scorecard tests it on 50 of your own cases in two weeks, for $5,000.
›References (6)
- Anthropic: Pricing
- Anthropic: Prompt caching
- OpenAI: Prompt caching
- Chen, Zaharia and Zou: FrugalGPT, How to Use Large Language Models While Reducing Cost and Improving Performance (arXiv)
- Ong et al.: RouteLLM, Learning to Route LLMs with Preference Data (arXiv)
- Epoch AI: LLM inference prices have fallen rapidly but unequally across tasks
Related work
Case studies from our projects on the same subject.
NenoDoc Lexicon by Neno Technologies
GovTech · Archive knowledge workspace
Archive indexers fix grammar and style without a name, date or figure changing
AI rewrites can quietly alter names and numbers. Ours edits only flagged spans, and approved terms are locked before the model sees them.
Our own product
Other software · AI support assistant
Visitors get answers from each company's own content, and a person when needed
Bots that answer from the wrong content lose visitors. Each chatbot in our assistant answers from its own knowledge base and hands off to an agent.
SovrenAI
Legal Tech · TITO, an AI claim verification engine
Every verdict traces to the founder's own rules, with the model only suggesting
A founder's AI-coded prototype could not be measured or audited; now rules anchor every verdict and each answer shows how it was reached.
More on AI in production
AI in production
LLMOps for SaaS: keep AI features working in production
LLMOps for product teams: evaluation gates, prompt and model versioning, tracing, regression checks, cost per task, kill switches and model upgrades.
AI in production
How to reduce AI infrastructure cost in production
How to reduce AI infrastructure cost in a live SaaS product: measure per tenant, trim context, cache, route models, batch, and place inference by the data.
AI in production
AI development cost: what production AI costs in SaaS
AI development cost in a live SaaS product: inference, retrieval, data movement and engineering, with bands built from published model prices.
AI in production
Which AI pricing model works when every answer costs money?
Build an AI pricing model from cost per action: decide which plans trigger expensive AI work and how often, then enforce limits on the server.
AI in production
AI agent monitoring: catch regressions in production
AI agent monitoring for live SaaS products: what to trace on every run, which user signals to watch, how to score traces and when to roll a change back.
AI in production
What keeps an LLM in production working for years?
Keeping an LLM in production working for years depends on stable interfaces, validated inputs and outputs, tests and planned model upgrades, not on prompts.
Your customers already expect AI from your product.
Let us make it real inside the product you run today.
