AI features are usually billed by tokens: what you send the model (instructions, context and the user's message) and what it sends back, multiplied by the provider's price per million tokens, with output usually priced higher than input. The biggest cost driver is long context repeated on every request. Caching, using a smaller model for easy tasks, shorter answers and per-user daily limits keep costs predictable.
- how much does it cost to run ai in an app
- what is a token in ai pricing
- how to reduce llm api costs
- do arabic prompts use more tokens
- prompt caching explained
How much does it cost to run AI in your app?
If you are asking what AI features cost to run in your app, the basic rule is simple: you pay the model provider by the number of tokens it reads and writes. Every request your app sends contains fixed instructions, context (products, documents, chat history) and the user's message, and every answer the model returns is billed too. There is no single number that fits everyone, but you can estimate your cost with reasonable accuracy before launch.
This is separate from the cost of building or hosting the app. It is a variable running cost that grows with usage, which is why it needs a plan from day one. For the cost of building itself, see How much it costs to build an app with AI.
| Cost component | When it applies | Note |
|---|---|---|
| Input tokens | Every request | Includes instructions, context and the user's message |
| Output tokens | Every answer | Usually priced higher than input |
| Embeddings | When indexing content for semantic search | Mostly one-off, then on updates |
| Vector storage | Semantic search and RAG | Part of your database cost |
| Special features | Images, audio, tools | Billed differently depending on the provider |
What is a token, and why can Arabic cost more?
A token is the unit a model splits text into: a whole word, part of a word or a punctuation mark. In English, a common word is often a single token. Arabic words carry prefixes and suffixes (one Arabic word can mean 'and they will write it'), and many tokenizers break them into more pieces, so Arabic text can use more tokens for the same meaning on some models.
The gap varies a lot between models, and newer models have improved on Arabic. So don't rely on a rule of thumb: take ten real messages from your customers, send them to the model you plan to use, and log the actual token counts. That number matters more than any published estimate. For more on Arabic performance, read Arabic language models.
How to estimate your monthly bill before launch
Estimating does not require complicated spreadsheets. You need four numbers from your own tests, plus the price of your chosen provider from its official pricing page:
- 1Average input tokens per request
Instructions + context + user message. Measure it from twenty test requests.
- 2Average output tokens per request
The real answer length. A three-bullet summary is far shorter than an open chat reply.
- 3Requests per active user
A support chat may contain several messages, and each message is a separate request that resends the context.
- 4Monthly active users
Use a conservative estimate, then double it to test the worst case, especially for seasons like Ramadan and White Friday.
- 5Multiply and add a buffer
(input × input price + output × output price) × requests × users, then add a buffer for testing, errors and retries.
An illustrative example without prices: a 6-message support chat where every message resends an 800-token system prompt plus the full history. By the sixth message, input may be several thousand tokens for a short reply. That shows how accumulated context, not the answer, is what drives the bill.
Seven ways to cut AI costs without losing quality
- Cache repeated results: a product's review summary or the answer to a common question (opening hours, return policy) does not need regenerating every time.
- Use prompt caching: many providers discount the fixed, repeated part of a request; always put fixed instructions first.
- Trim chat history: send the last few messages plus a short summary of earlier ones, not the full log.
- Send only relevant context: in RAG, three relevant passages beat a whole document on both quality and cost. Respect the context window; don't fill it just because it is there.
- Use a smaller model for easy tasks: classification, extraction and text normalization don't need the strongest model. Keep the big one for hard tasks.
- Cap answer length: ask for a fixed format and a max-token limit, since output is usually the pricier part.
- Batch non-urgent work: writing 200 product descriptions or tagging yesterday's tickets can run overnight in one go, and some providers offer lower prices for batch processing.
The cheapest token is the one you never sent.
Which limits should you set before launch?
An AI feature with no limits is an open invitation to surprises: one user pastes an entire book, or a bot fires thousands of requests at the chat widget on your site. Limits are not stinginess; they protect your business.
| Limit | What it prevents | A sensible starting point |
|---|---|---|
| Per-user daily cap | Heavy use from a single account | A reasonable message count, then a friendly 'come back tomorrow' |
| Message length cap | Huge pasted texts | Truncate long input or summarize it first |
| Anonymous visitor cap | Bots | Phone (OTP) sign-in before heavy use |
| App-wide daily budget | A surprise bill | An alert as you approach it, plus a fallback reply once exceeded |
| Retry cap | Costly error loops | Two retries, then a clear error message |
What to monitor after launch
Total cost alone tells you little. Tie it to business value so you know whether the feature is worth what you pay:
- Cost per support conversation compared with an agent handling the same chat.
- Cost per completed order when the assistant helps sell.
- Share of requests served from cache: the higher it is, the lower your cost.
- Top ten users by consumption: real customers or abuse?
- Response time ([latency](/{lang}/wiki/glossary/latency/)): bigger models are usually slower, and slowness kills the experience on mobile.
Review these numbers weekly in the first month, then monthly. If costs jump suddenly, start by looking for instructions that grew longer or context that started being sent in full after a change.
Build AI features with predictable costs in Fanann
When you build an AI feature in Fanann, ask the agent to include cost controls in the plan itself, not as an afterthought: caching, per-user limits, a usage log in your admin dashboard, and an automatic fallback reply once the budget is exceeded. That way you launch knowing the ceiling.
In my app's chat assistant, add cost controls: store answers to common questions (opening hours, delivery, returns) and reuse them instead of calling the model. Send the model only the last 6 messages plus a short summary of earlier ones. Put the fixed instructions at the start of every request. Cap replies at 150 words. Daily limit of 30 messages per phone-verified user and 5 for anonymous visitors. An app-wide daily budget with an alert to the admin at 80 percent, and once exceeded the assistant replies with a handoff to customer service on WhatsApp. Add an admin page showing daily tokens, requests and the top users by consumption. Show me the plan first.
Try it in FanannIf you have not built the feature yet, start with Add AI features to your app, then come back to this checklist before launch.
Key takeaways
- Your bill = input tokens × input price + output tokens × output price, and output usually costs more.
- Repeated context (long instructions, full chat history, documents) is the biggest consumer in most apps.
- Arabic text can use more tokens than English for the same meaning, depending on the model; measure it yourself.
- Caching results and the fixed prompt prefix, and a smaller model for simple tasks, cut costs noticeably.
- Set per-user and per-day limits, and track cost per conversation or per order as a core metric.
Frequently asked questions
How much does it cost to use ChatGPT or Claude inside my app?
Does Arabic text use more tokens than English?
What is prompt caching?
How do I avoid a surprise AI bill?
Is a smaller model good enough?
Ask your AI assistant about this
Copy this prompt into the AI assistant you use, then add the details of your own case.
I am reading this guide: “What AI features cost to run: tokens, caching and usage limits” https://fanann.com/en/blog/ai-running-costs-tokens/ My question: how much does it cost to run ai in an app Use that page as a source and explain the answer step by step for my situation, tell me what to check before I start, and cite the page link.