Contents
LLM API costs arise with every request to a language model and are usually billed per processed token – separately for input and output. Calculating them properly before launch avoids unpleasant surprises and lets you build AI features economically into your prices and plans. This article provides a simple formula, a worked example and the most effective levers for reducing costs.
How LLM providers bill
Most language model providers price per million tokens. A token is a fragment of a word; as a rough guide, one English word is around one token, with longer or compound words split into several. You are billed for:
- Input tokens: everything sent to the model – system instructions, conversation history, inserted documents and the user's question.
- Output tokens: the generated answer. Per token, these are usually considerably more expensive than input tokens.
- Internal reasoning: with some models that "reason" extensively, intermediate thinking steps are also billed as output even though the user never sees them.
Depending on the feature, there are also costs for embeddings (for search and RAG), image or audio processing, and your own infrastructure. Prices vary by a large factor between providers and model tiers and change regularly – always calculate with your provider's current list prices.
The formula for your cost calculation
For a solid first estimate, this calculation per AI feature is enough:
Monthly cost = requests per month × (input tokens × input price + output tokens × output price)
How to determine the values:
- Requests per month: active users × uses of the feature per user per month. Plan a realistic and a peak scenario.
- Input tokens per request: system instructions + context sent along + average user input. In chats this grows with every turn, because the history is sent again.
- Output tokens per request: average answer length, plus reasoning tokens if applicable.
- Prices: the chosen model's current price per million tokens, converted to per token.
- Buffer: 20–30 % for retries, failed attempts and testing is a sensible rule of thumb.
The most reliable way to get token counts is a prototype: API responses include the tokens actually consumed, which you can simply log.
Worked example: support assistant in an app
An example with deliberately fictional prices to illustrate the principle: assume EUR 1 per million input tokens and EUR 5 per million output tokens for a mid-tier model.
| Item | Assumption | Result |
|---|---|---|
| Requests per month | 2,000 active users × 10 questions | 20,000 |
| Input tokens per request | 800 system instructions + 1,800 document excerpts + 400 question and history | 3,000 |
| Output tokens per request | Answer of a few sentences | 300 |
| Input cost | 60M tokens × EUR 1 | EUR 60 |
| Output cost | 6M tokens × EUR 5 | EUR 30 |
| Total incl. 25 % buffer | – | approx. EUR 113 per month |
That is roughly 6 cents per active user per month. Two takeaways: first, input dominates here because the document excerpts make up the bulk. Second, a top-tier model ten times as expensive would also multiply costs by ten – model choice is the single biggest lever. How to find the right one is covered in Which AI model for my app?
Cost drivers that are often overlooked
- Growing conversation history: in long chats, the entire history is resent with every message, so the cost per message rises with conversation length.
- Agents and tool calls: an AI assistant that carries out several steps on its own often makes multiple model calls per user action.
- Overly generous context: sending ten instead of three document chunks in RAG triples the input without necessarily improving the answer.
- Abuse: without per-user limits, an open chat can be misused as free access to a language model.
- Development and testing: automated quality tests with many test questions also incur API costs.
Eight levers to reduce LLM API costs
- Choose the smallest sufficient model: for classification, extraction or standard questions, small and inexpensive models are often enough.
- Model routing: simple requests go to a cheap model, only complex ones to a large model.
- Use prompt caching: many providers discount repeatedly sent, unchanged prompt prefixes such as long system instructions.
- Tighten the context: fewer but more relevant document chunks; summarise older parts of a conversation instead of resending them in full.
- Limit output: set a maximum answer length and instruct the model to be concise.
- Cache answers: do not regenerate frequent, identical questions every time.
- Batch processing: handle non-urgent tasks, such as nightly analyses, via cheaper batch interfaces where the provider offers them.
- Limits and budgets: set per-user quotas, rate limits and budget alerts with your provider.
Reflecting AI costs in your business model
Running AI costs scale with usage – unlike many classic server costs, which tend to rise in steps. Your pricing model should reflect this. Common options include AI features only in premium plans, monthly fair-use quotas, or a credit system for particularly expensive features. Monitoring that records token consumption per feature and per user is essential, so you can spot outliers and adjust prices based on data.
API costs are only one part of operating costs. Hosting, databases, monitoring and maintenance come on top; our article on calculating backend and server costs realistically gives an overview. How to plan the development of an AI assistant is covered in integrating an AI chatbot into your app.
Agentic coding workshop for your team? From €799 net – request a quote by e-mailConclusion
LLM API costs can be predicted well with a simple formula: requests times tokens times price, plus a buffer. The biggest levers are model choice, a lean context and clear usage limits. Measure actual consumption early with a prototype, monitor it continuously after launch and reflect it in your pricing. That keeps AI features economical even as your user base grows. If you are planning an app with AI features, we are happy to calculate development and operation together – request your fixed-price offer via the offer wizard.
Frequently Asked Questions
What is a token and how many tokens does a text have?
A token is a word fragment that the language model processes as a unit. An English word is roughly one token on average; the exact count is provided by each provider's tokenizer tools or API responses.
Why are output tokens more expensive than input tokens?
Generating text is more compute-intensive for the model than reading it, because each token is computed one at a time. That is why it pays to keep answers deliberately concise.
How much does an AI feature cost per user?
It depends heavily on the model, context size and frequency of use, ranging from fractions of a cent to several euros per user per month. A prototype with logged token consumption gives the most reliable figure.
Is a self-hosted open-source model cheaper?
At very high, steady volume it can pay off; with low or fluctuating usage, server and operating costs are usually higher than API costs. Data protection is often the more important argument for self-hosting.