Why is your LLM bill unpredictable?
The same prompt, executed twice with two different models, can generate a cost difference close to 100×. Yet, the billing mechanics of large language models (LLMs) rest on four simple variables that most IT teams ignore when estimating a project. This article gives you the method to estimate your consumption before deploying, then to reduce costs without sacrificing quality.
Warning on pricing
The prices mentioned in this article are illustrative examples from a given period. LLM API pricing evolves regularly — usually downward. Always check official pricing pages from providers before any project estimation.
Prerequisites: four concepts to master before any calculation
Before opening a calculator, clarify these four fundamental notions.
The token: the universal unit of measurement
A token is the minimal text fragment processed by an LLM. It's not a whole word: in practice, a token corresponds to approximately four characters, or three quarters of an English word (slightly less for French). Order of magnitude to remember:
- 1,000 tokens ≈ 750 words ≈ 1.5 pages of text
- The prices displayed by providers are always expressed per million tokens (abbreviated M tok), which avoids writing six decimals.
Input vs Output: two counters, two prices
Each API call generates two types of consumption:
- Input: everything you send to the model — the question, system instructions, conversation history, injected documents.
- Output: everything the model generates in response.
Output is systematically 3 to 6 times more expensive than input, regardless of the provider. The reason is architectural: the model reads your input text in parallel, but produces its response one token at a time, re-reading everything that precedes at each step. This sequential process ties up the GPU much longer.
Prompt caching
Prompt caching allows you to reuse a prompt prefix already sent (system instructions, fixed reference document) without recharging it at full price. The cached portion is re-read at approximately 1/10th of the normal price, meaning up to 90% savings on that portion.
TCO: don't confuse API bill with project cost
TCO (Total Cost of Ownership) refers to all expenses related to an LLM project, not just the token bill. This distinction is critical when estimating — we return to it in detail below.
What really varies your bill
Variable #1: model choice (factor up to 100×)
It's the most powerful lever. For illustration, here's the order of magnitude of pricing gaps between model categories:
| Category | Example models | Input ($/M tok) | Output ($/M tok) |
|---|---|---|---|
| High-end | Claude Opus 4, GPT-5 | ~5 | ~25-30 |
| Mid-range | Claude Sonnet 5 | ~3 | ~15 |
| Economic | Claude Haiku 4.5, GPT-4.1 mini | ~0.1-1 | ~0.4-5 |
| Low-cost challengers | DeepSeek V3, Gemini Flash | ~0.1-0.14 | ~0.28-0.40 |
Variable #2: the length of generated responses
Since output costs several times more than input, a task producing long responses will be significantly more expensive than a task returning a single word or score. This is a parameter often overlooked during initial estimation.
Variable #3: exponential growth of conversational context
An LLM has no persistent memory between calls. To maintain conversation coherence, your application must return the entire history with each turn. Direct consequence:
- At 1st message: you pay for 1 question.
- At 10th message: you pay for 9 previous exchanges + the new question as input.
Cost therefore doesn't progress linearly with message count — it accelerates. An agent chaining many steps can generate a bill well above predictions for this reason alone.
Technical prerequisites to estimate an LLM project
Before launching any estimation, ensure you have the following elements:
- Access to an API account with the intended provider(s) (Anthropic, OpenAI, Google, etc.)
- A tokenizer to precisely count tokens in your prompts. OpenAI provides Tiktoken; Anthropic offers a counter in its console.
- Official pricing pages of targeted models, checked the day of estimation.
- An estimate of monthly volume of requests (number of calls, not number of users).
- A representative example of a typical request, with its system prompt, average history and expected response.
Estimate your monthly bill: the 5-step method
Build a representative typical request
Write a complete example of an API call as it will occur in production: system instructions, injected context (documents, data), average history and user question. Be realistic — neither too short nor artificially long.
What you should get: a complete prompt that you'll measure in the next step.
Count tokens in your typical request
Use a tokenizer suited to your target model. For OpenAI, install Tiktoken:
1import tiktoken2 3enc = tiktoken.encoding_for_model("gpt-4o")4tokens_input = enc.encode(your_complete_prompt)5print(f"Input tokens: {len(tokens_input)}")For output, estimate the average length of expected responses (in tokens) from a few real examples or a quick prototype.
What you should get: two figures — average input tokens and average output tokens per request.
Calculate the cost of a single request
Apply the formula:
1Unit cost = (tokens_input / 1,000,000 × price_input) + (tokens_output / 1,000,000 × price_output)Concrete example — documentation support chatbot on Claude Haiku 4.5 (1 $/M input, 5 $/M output):
- Input: 2,000 tokens → 2,000 / 1,000,000 × 1 = 0.002 $
- Output: 400 tokens → 400 / 1,000,000 × 5 = 0.002 $
- Total: 0.004 $ per request
Run the same calculation on the equivalent high-end model to measure the gap.
What you should get: a unit cost in dollars or cents per API call.
Project over your monthly volume
Multiply the unit cost by the estimated number of requests per month:
1Estimated monthly bill = unit cost × monthly request volumeReturning to the previous example:
- 100,000 requests/month × 0.004 $ = 400 $/month on Haiku 4.5
- 100,000 requests/month × 0.02 $ = 2,000 $/month on Opus 4 — or 5× more expensive for the same task
What you should get: a low/high range depending on the models you're considering.
Validate and adjust with production logs
In the first weeks of deployment, compare your estimation to actual data. All providers expose consumption metrics in their console:
- Anthropic Console: Usage tab with input/output detail by model
- OpenAI Platform: Usage section with CSV export
- Azure AI Foundry: metrics in the Azure portal, under Monitoring
What you should see: actual input and output tokens match your estimation ±20%. A larger gap indicates a longer conversation history than expected or oversized system prompts.
Four levers to reduce your bill
1. Choose the smallest model capable of the task
Classifying an email, extracting a date, rephrasing short text: economical models (Haiku, GPT-4.1 mini, Gemini Flash, DeepSeek V3) handle this well. Reserve high-end models for complex reasoning, multi-step analysis or critical content generation.
2. Enable prompt caching on your fixed prefixes
If your application returns the same system instructions or reference document with each call, enable caching with the provider. The cached portion is charged at approximately 1/10th of normal rate. Ideal use case: a long fixed context (product documentation, business rules base) followed by a variable question.
3. Use the Batch API for deferrable tasks
Most providers offer a batch processing API (batch): you send a set of requests, they're processed in the background (usually within 24 hours) and charged at -50% off input and output. Applicable for classifying thousands of documents, generating summaries in bulk or enriching a database. Unusable for a real-time chatbot.
4. Control conversational context size
Rather than returning the entire history indefinitely, implement a rolling summary strategy: condense the last N exchanges into a few lines and inject only the essentials. This technique alone can significantly reduce costs for long conversations.
Cost debugging tip
Add structured logging to each API call that records prompt_tokens, completion_tokens and the model used. Aggregate this data in a simple dashboard (Grafana, Power BI, or even a spreadsheet) to identify abnormally expensive requests before they hit the bill.
TCO: don't budget only for tokens
The API bill is only the tip of the iceberg. A production LLM project involves other cost items often underestimated:
- Development and maintenance: developer time to build, test and maintain prompt pipelines and integrations.
- Infrastructure: vector database, application hosting, document update pipeline (essential for a RAG chatbot).
- Retries: calls that fail (timeout, parsing error) are retried — and recharged.
- Monitoring: tools for tracking quality and costs (LangSmith, Helicone, Azure Monitor depending on your stack).
- Human supervision: if your use case requires validation or human takeover on certain responses.
Frequent estimation error
Presenting the estimated API bill as the total project cost is an error most teams make at first estimation. Development, infrastructure and monitoring often represent a cost greater than token consumption itself, especially in the initial phase.
Managed API vs self-hosting: how to choose?
When your request volume becomes very large, the question of self-hosting an open-weight model (whose weights are public, like Llama or Mistral) naturally arises.
| Criterion | Managed API (pay-per-token) | Self-hosting (rented GPU) |
|---|---|---|
| Cost structure | Variable — you pay what you consume | Fixed — GPU billed hourly, traffic or not |
| Main advantage | Zero fixed cost, ideal for low volume | Very low cost per request at high volume |
| Main disadvantage | Higher unit cost at very high volume | Operational complexity, ML team required |
| Breakeven point | — | Depends on volume and model — calculate case by case |
| To start | Recommended | Not recommended |
The practical rule: start with the API, switch to self-hosting only when your traffic is large, stable, and the API bill becomes a structural expense item. To prototype free with open-weight models, platforms like OpenRouter provide access to models like Llama or DeepSeek R1 with rate limits.
Troubleshooting
Your bill explodes without visible increase in user count → Check conversation history length injected. It's likely your application is accumulating context without truncating it. Add logging of input token count per call to identify the drift.
Prompt caching doesn't seem to work → Caching is only enabled if the exact prefix (character for character) is repeated call to call and exceeds a minimal token threshold (usually 1,024 tokens at Anthropic). Verify your system instruction isn't dynamically modified at each call.
Your initial estimation is very far from actual bill → The most frequent cause is poor estimation of output tokens (responses are longer than expected) or unconsidered conversation history in the calculation. Relaunch estimation with real averages from production logs.
Key points to remember
- The chosen model is the most impactful parameter — up to 100× difference between the most economical and most powerful.
- Output costs 3 to 6× more than input: a task generating long responses is significantly more expensive.
- Conversation history is recharged each turn: cost grows faster than message count.
- Estimation method: cost of an average request × monthly volume = reliable order of magnitude.
- Reduction levers: small model suited to task, prompt caching, batch API, controlled context.
- TCO ≠ API bill: budget development, infrastructure, retries and monitoring.
- Self-hosting: pertinent only at high stable volume — always start with the API.



