AI Answer Library
Short answer
The formula is: cost per call = (input tokens × input price) + (output tokens × output price), multiplied by calls per day and days. Three things drive it. Input and output are priced separately, and output is usually the more expensive side. Retrieved passages in a RAG prompt and accumulated multi-turn history push input tokens far beyond intuition. And whatever hits the context cache is typically billed at a lower rate. Do not copy anyone's unit prices — vendors adjust them every few months, so use the current official rate card together with token counts you measured yourself.
The table deliberately omits unit prices: vendors revise rate cards every few months, so any figure written here would go stale and mislead. What it gives instead is the order-of-magnitude relationship and the cost drivers, which are comparatively stable — a plain Q&A call and a long-document extraction call can differ by two orders of magnitude in token count, and their cost levers are entirely different. Find your scenario, identify the dominant variable, then pull the current unit price from the official rate card and put it into the formula.
| Scenario | Order of magnitude per call | Dominant cost driver | What to optimise |
|---|---|---|---|
| Single-turn short Q&A, no retrieval | Hundreds of input tokens, hundreds of output | System prompt length and how verbose the output is | Compress the system prompt, cap output length, enable context caching |
| RAG knowledge-base Q&A | Thousands to tens of thousands of input tokens, hundreds of output | top-k count × chunk length; the input side dominates completely | Lower top-k, rerank so only the best passages are sent, chunk by structure to cut redundancy |
| Long-document summarisation and contract extraction | Tens of thousands to over a hundred thousand input tokens, thousands of output | Total document length, and whether the whole text is re-sent every time | Pre-filter with rules and send only relevant sections, process in segments then merge, cache the fixed prefix |
| Multi-turn agent with tool calls | Tens of thousands cumulatively per task, growing with step count | Full history and tool definitions re-sent at every step; retries double it | Summarise history, trim tool schemas, cap the step count, fail fast |
| Batch offline processing: classification and tagging | Small per item, but total = per item × number of items | Item count, and using a model far stronger than the task needs | Use a smaller or local model, use the batch endpoint, filter with rules first where possible |
Step one: do not guess token counts, measure them. Take 30–50 real requests, run them through the target vendor's tokeniser, and record actual input and output tokens per request, keeping both the mean and the P90 — P90 matters more, because long-tail requests routinely contribute most of the bill. Step two: estimate volume from existing business data — how many cases are handled today, what share will route through AI, and how many model calls one case triggers on average. Step three: apply the formula — monthly cost = (mean input tokens × input price + mean output tokens × output price) × calls per day × 30. Step four: multiply by 1.3 to 1.5 to cover retries, evaluation runs and the waste of a trial period, all of which always appear on a real invoice. Step five: rerun it with P90 instead of the mean and treat that as the budget ceiling. After a month of real traffic, come back and correct the numbers; everything before that is an order-of-magnitude estimate.
One: cut the input. In a RAG setup, dropping top-k from ten to three while adding a reranker usually saves tokens and improves accuracy at the same time — a rare win on both sides. Two: enable context caching. Put the long system prompt and fixed tool definitions at the very front of the prompt and keep them byte-identical; once cached, that portion costs far less, and note that a single changed character invalidates it. Three: route by difficulty. Send simple classification, intent detection and format conversion to a small or local model, and reserve the flagship for requests that genuinely need reasoning — usually the largest saving available and the one most often overlooked. Four: constrain output — require JSON, cap the length, forbid restating the question. Five: trim multi-turn history with a sliding window or periodic summarisation. Six: use batch endpoints for offline work, where many vendors discount non-realtime processing substantially. After the first three, most workloads land at an acceptable bill.
Where this applies
People also ask
How much does it cost for a company to self-host a large language model?
Self-hosted LLM or public API — how do I choose?
What server specs do you need to self-host a large language model?
Ygg Lab Token — API Quota Gateway
Every model call, clear and in control — nine upstream provider types behind a single sk- key, with quota, logs and billing you own.
Meeting Management — Private-Deployed Platform
A ¥19,800 perpetually licensed, self-hosted meeting platform — 8 modules, any BCP 47 language, 4-channel international payment, AI site builder + Copilot, dual-QR check-in. v0.6.0 in production.