Estimating an LLM application’s running cost does not require perfect forecasting. It requires a repeatable model that connects traffic, token usage, provider pricing, caching, retries, and operational overhead. This guide gives you a practical AI API budget template, formulas for token cost estimation, worked examples, and a review process you can reuse before launch and after your application changes.
Overview
An LLM cost estimate is best treated as a planning range rather than a single precise number. Your actual bill depends on the model selected, the number of requests, input and output token volumes, cached requests, failed or repeated calls, and the pricing rules of the provider you use.
The basic calculation is:
Estimated cost = input token cost + output token cost + optional tool or platform costs
For a production estimate, add the effects of retries, fallback models, batch processing, and caching. Then convert the result into useful operating measures such as cost per request, cost per active user, cost per completed workflow, and expected monthly spend.
Keep the pricing table separate from the application assumptions. Provider prices and model availability can change, while your expected request volume or prompt structure may remain stable. Separating these inputs makes the budget easier to refresh without rebuilding the whole calculation.
How to estimate LLM API costs
1. Define the billable unit
Start by deciding what one unit of work means for your application. It might be one chat turn, one document summary, one support ticket, one generated report, or one completed agent workflow. A workflow may contain several model calls, so do not assume that one user action equals one API request.
For each unit, record:
- Average input tokens sent to the model.
- Average output tokens returned by the model.
- Expected number of model calls.
- Estimated retry rate and fallback usage.
- Whether some input tokens qualify for provider-supported caching.
2. Separate input and output tokens
Most LLM pricing schedules distinguish between input and output tokens. Use separate columns in your calculator rather than combining them into one total. A long system prompt, conversation history, retrieved documents, tool results, and the user’s latest message can all contribute to input usage. The generated answer contributes to output usage.
Use these formulas:
- Input cost per request = input tokens ÷ pricing unit × input price
- Output cost per request = output tokens ÷ pricing unit × output price
- Total request cost = input cost + output cost
The provider’s pricing unit may be expressed per million tokens, per thousand tokens, or another unit. Copy the unit directly into your spreadsheet and convert your token estimate to match it. This prevents a common error: applying a per-million-token price to a raw token count without dividing by one million.
3. Scale from one request to monthly usage
Once you have a request-level estimate, multiply it by your expected monthly volume:
Monthly base cost = cost per request × monthly completed requests
Then model less predictable usage separately. For example:
Expected monthly API cost = base cost × (1 + retry rate + fallback rate)
This is a planning approximation. If retries and fallbacks use different models or token volumes, create separate rows for them instead of applying one percentage to the entire bill.
4. Model caching explicitly
If your provider offers prompt or input caching, identify which part of the prompt is stable. A long system instruction or repeated document prefix may be a candidate, while the user’s latest message is usually variable. Record the cached-token share and the applicable cached-input price in a separate column.
A useful structure is:
- Uncached input tokens per request.
- Cached input tokens per request.
- Output tokens per request.
- Cache hit rate.
- Any cache storage or minimum-duration assumptions.
Do not treat caching as an automatic discount. It changes the price of eligible tokens only when the provider’s rules are met, so validate the implementation with real request logs.
Inputs and assumptions for an AI API budget template
Create one worksheet for provider pricing and another for product assumptions. The following layout is suitable for a spreadsheet, database table, or internal cost calculator.
| Input | Example field | Why it matters |
|---|---|---|
| Model | Model name and version | Prices, context limits, and capabilities differ. |
| Input price | Price per provider pricing unit | Used to calculate prompt and context cost. |
| Output price | Price per provider pricing unit | Generated text can have a different rate. |
| Average input tokens | Tokens per model call | Captures prompts, history, retrieval, and tools. |
| Average output tokens | Tokens per model call | Captures the generated response. |
| Calls per workflow | Number of model calls | Agent and multi-step workflows multiply usage. |
| Monthly workflows | Completed units per month | Converts unit cost into a forecast. |
| Retry rate | Expected additional calls | Accounts for timeouts, validation failures, or transient errors. |
| Cache hit rate | Share of eligible input | Helps estimate cached and uncached input costs. |
Use ranges for uncertain inputs. For example, create low, expected, and high cases for monthly workflows, input tokens, output tokens, and retry rates. A range is more useful than false precision when the application has not launched.
Measure tokens rather than estimating them from character counts whenever possible. A tokenizer or provider usage field can give you a closer approximation for your chosen model. If you are still designing the application, run representative prompts through the intended model and record the token counts for short, typical, and unusually large inputs.
Worked examples
The following figures are illustrative placeholders, not current provider prices. Replace them with the prices from the provider and model you are evaluating.
Example 1: A document summariser
Suppose one summary request uses 6,000 input tokens and produces 800 output tokens. Assume the selected pricing table uses a unit of one million tokens, with an illustrative input rate of £2 per unit and output rate of £8 per unit.
- Input cost: 6,000 ÷ 1,000,000 × £2 = £0.012
- Output cost: 800 ÷ 1,000,000 × £8 = £0.0064
- Total per summary: £0.0184
At 10,000 summaries per month, the base estimate would be £184 before retries, caching effects, taxes, platform charges, or other services. If your real documents vary substantially in size, calculate separate short, typical, and long-document scenarios rather than using only the average.
Example 2: A multi-step support workflow
Imagine a support workflow that classifies a ticket, retrieves relevant information, drafts a response, and performs a final quality check. If each ticket triggers four model calls, calculate each call separately. The classifier may use a small prompt and short output, while the drafting and review calls may include conversation history and retrieved context.
The worksheet should contain one row per call:
- Classification: input tokens, output tokens, model, and cost.
- Retrieval-aware draft: input tokens including retrieved content, output tokens, model, and cost.
- Response refinement: input and output usage.
- Quality check: input and output usage.
Add the rows to obtain the cost per ticket. This approach reveals which step is responsible for most usage and makes model routing easier. For instance, a lightweight model might handle classification while a more capable model is reserved for complex drafting, subject to your quality tests.
Example 3: Per-user budgeting
To set a user or feature budget, divide the monthly allowance by the expected number of active users or completed workflows. If a feature has a monthly budget of £500 and is expected to process 25,000 workflows, its target average cost is £0.02 per workflow. Compare that target with your calculated cost, then decide whether to reduce context, limit output length, add caching, route simple requests to another model, or change the product allowance.
When to recalculate your estimate
Revisit your LLM API cost calculator whenever a pricing input, usage pattern, or application design changes. At minimum, review it before launch and during regular monthly spend checks.
- Provider pricing changes: Update input, output, cached-input, batch, and model-specific rates.
- Model changes: Recheck context limits, tokenisation behaviour, output quality, and pricing units when changing models or versions.
- Prompt changes: Measure the effect of longer system prompts, added examples, conversation history, or retrieved documents.
- Traffic changes: Recalculate after a launch, new customer segment, seasonal increase, or feature adoption change.
- Reliability changes: Review retry, timeout, validation-failure, and fallback rates using application logs.
- Workflow changes: Count new agent steps, tool calls, summarisation passes, and evaluation requests.
- Budget reviews: Compare forecast cost with actual usage by model, feature, team, and user cohort.
For a practical monthly review, export request-level usage, group it by feature and model, and compare actual input and output tokens with the assumptions in your template. Investigate the largest variance first. A small increase in average context can matter more than a small change in user count when every request carries a long history or retrieval payload.
Finally, keep a dated pricing snapshot and record the assumptions behind each forecast. Link the estimate to your prompt tests, observability runbook, and workflow documentation. The related LLM cost optimisation guide can help turn the forecast into ongoing controls, while the LLM observability runbook provides a useful framework for connecting cost changes with reliability and quality signals.
Start with one representative workflow today: measure its tokens, enter the current provider rates, calculate the low, expected, and high cases, and set a review date. That simple baseline gives your team a defensible starting point for decisions about prompts, models, traffic, and budgets.