app-entwickeln-lassen.de LogoApp entwickeln lassen

AI Features in Apps

Calculating LLM API Costs: What AI Features Cost to Run

app-entwickeln-lassen.de editorial team 6 min read
Contents
  1. How LLM providers bill
  2. The formula for your cost calculation
  3. Worked example: support assistant in an app
  4. Cost drivers that are often overlooked
  5. Eight levers to reduce LLM API costs
  6. Reflecting AI costs in your business model
  7. Conclusion
  8. Frequently Asked Questions

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:

  1. Requests per month: active users × uses of the feature per user per month. Plan a realistic and a peak scenario.
  2. 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.
  3. Output tokens per request: average answer length, plus reasoning tokens if applicable.
  4. Prices: the chosen model's current price per million tokens, converted to per token.
  5. 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.

ItemAssumptionResult
Requests per month2,000 active users × 10 questions20,000
Input tokens per request800 system instructions + 1,800 document excerpts + 400 question and history3,000
Output tokens per requestAnswer of a few sentences300
Input cost60M tokens × EUR 1EUR 60
Output cost6M tokens × EUR 5EUR 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

  1. Choose the smallest sufficient model: for classification, extraction or standard questions, small and inexpensive models are often enough.
  2. Model routing: simple requests go to a cheap model, only complex ones to a large model.
  3. Use prompt caching: many providers discount repeatedly sent, unchanged prompt prefixes such as long system instructions.
  4. Tighten the context: fewer but more relevant document chunks; summarise older parts of a conversation instead of resending them in full.
  5. Limit output: set a maximum answer length and instruct the model to be concise.
  6. Cache answers: do not regenerate frequent, identical questions every time.
  7. Batch processing: handle non-urgent tasks, such as nightly analyses, via cheaper batch interfaces where the provider offers them.
  8. 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-mail

Conclusion

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.

This article was written by the editorial team of app-entwickeln-lassen.de – the app and AI development service of jocapps GmbH, based in Freiburg, Germany, and building apps since 2014. The content is for general information and does not replace individual (legal) advice.

You might also like

AI Features in AppsOn-Device AI: Running Artificial Intelligence Directly on Smartphones

On-device AI explained: when AI on the smartphone beats the cloud, which frameworks exist and what to watch for in implementation and device support.

6 min read
AI Features in AppsAI Image Recognition in Apps: Use Cases and Implementation

AI image recognition in apps: which tasks it reliably solves today, which implementation paths exist and how to get from idea to a production-ready feature.

6 min read
AI Features in AppsRAG Explained: Making Company Knowledge Usable With AI in Your App

RAG explained: how retrieval-augmented generation makes your company knowledge usable in apps, which components you need and how to avoid typical mistakes.

6 min read
AI Features in AppsVoice Control and Speech Recognition in Apps: Technology and Practice

Voice control and speech recognition in apps: building blocks, technologies, privacy and UX rules so users can operate your app hands-free and reliably.

6 min read
AI Features in AppsAI Personalization in Apps: Recommendations Users Actually Want

AI personalization in apps: methods, data, cold start and privacy – how to build recommendations that feel relevant, not intrusive, and deliver results.

6 min read
AI Features in AppsAI Agents in Business Apps: Automating Processes That Matter

AI agents in business apps: which processes fit, how architecture, approvals and costs work – so your automation saves time reliably instead of adding risk.

7 min read