Estimate the monthly LLM bill for this RAG chatbot workload. Every user turn is a separate API call that re-sends the full prompt.
| Workload item | Value |
|---|---|
| Conversations per day | 50,000 |
| User turns per conversation | 6 |
| Input tokens per turn | 1,500 system prompt + 1,000 history (avg) + 2,000 retrieved context + 100 user message |
| Output tokens per turn | 250 |
| Price (illustrative) | $0.50 per 1M input tokens, $1.50 per 1M output tokens |
| Month | 30 days |
Show the answer and explanation
Correct answer: B, About $24,000 a month: 300,000 calls a day × 4,600 input tokens ≈ $690 plus ≈ $113 of output per day; input dominates because the whole context is re-sent on each new turn.
Explanation Cost Optimization
Work per API call, then scale up:
| Step | Value |
|---|---|
| Calls per day | 50,000 × 6 = 300,000 |
| Input tokens per call | 1,500 + 1,000 + 2,000 + 100 = 4,600 |
| Input per day | 300,000 × 4,600 = 1.38B tokens → $690 |
| Output per day | 300,000 × 250 = 75M tokens → $112.50 |
| Per day | $802.50 |
| Per month | × 30 ≈ $24,075 |
Input is about 86% of the bill, even though output tokens cost 3× more per token, because every turn re-sends the system prompt, history and retrieved chunks. That points to the biggest levers:
- Prefix caching of the 1,500-token system prompt: if cached tokens cost 10% of the normal rate, that alone saves ≈ $200 a day (≈ $6,000 a month, about 25%).
- Fewer or shorter retrieved chunks via reranking (e.g. top 3 instead of top 8).
- History summarisation or windowing instead of re-sending every turn verbatim.
- Routing easy turns to a cheaper model (cascade).
Where the distractors come from: counting one call per conversation instead of per turn (≈ $4,000); swapping the input and output prices (≈ $63,000); billing output at the input rate (≈ $22,000). Chat APIs are stateless: the model does not remember earlier turns unless they are re-sent.
Interview tip: present cost per conversation (here ≈ $0.016) alongside the monthly total, and show the cost breakdown by prompt component; it makes the optimisation discussion concrete.