Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path
Context Budget & Cost Planner
Add a system prompt, tool definitions, conversation history and retrieved context, then see your context window fill up and the cost per call — plus the bill at 1k and 1M requests — across model price tiers. An architecture planner, not a toy token counter.
Every turn of a conversation re-sends the whole context, so the bill depends on what sits in that context far more than on the user's question. This planner adds up the system prompt, tool definitions, retrieved documents and growing chat history, shows how the context window fills, and prices one conversation, a thousand conversations, a day and a month on one of three price tiers.
What it computes
Call the fixed part of every request B: system prompt + tool definitions + RAG context. Turn i of a t-turn conversation sends B, the i user messages so far and the i − 1 earlier replies:
input on turn i = B + i × u + (i − 1) × r
total input = t × B + u × t(t + 1)/2 + r × t(t − 1)/2
total output = t × r
peak context = B + t × (u + r)
cost/conversation = input/1M × P_in + output/1M × P_out
cost/day = cost/conversation × requests per day
cost/month = cost/day × 30
- u: user tokens per turn. r: output tokens per turn; each reply becomes history for the next turn.
- t: turns in one conversation. One "request" in the daily volume is one whole conversation.
- P_in, P_out: the selected tier's price per million tokens. The built-in tiers are $3/$15, $1/$5 and $0.25/$1.25.
The colored bar splits the peak context into system prompt, tools, RAG and history, where history is t × (u + r). Token counts are entered directly; the tool does not tokenize text.
A worked example
The defaults: a 900-token system prompt, 1,200 tokens of tool definitions, 3,000 tokens of RAG context, 150 user and 400 output tokens per turn, 8 turns, the $3/$15 tier and 10,000 conversations a day.
- Fixed context:
B = 900 + 1,200 + 3,000 = 5,100tokens, sent on all 8 turns, so 40,800 tokens. - User messages:
150 × 36 = 5,400. Replies re-sent as history:400 × 28 = 11,200. - Total input: 57,400 tokens. Output:
8 × 400 = 3,200. - Peak context:
5,100 + 8 × 550= 9,500 tokens, split 9.5% system, 12.6% tools, 31.6% RAG and 46.3% history. - Cost per conversation:
57,400/1M × $3 = $0.1722plus3,200/1M × $15 = $0.0480= $0.2202. - Scale: $220.20 per 1k conversations, $2,202.00 a day and $66,060 a month.
The same conversation on each tier:
| Tier | Per conversation | Per day | Per month |
|---|---|---|---|
| Frontier ($3 / $15) | $0.2202 | $2,202.00 | $66,060 |
| Mid ($1 / $5) | $0.0734 | $734.00 | $22,020 |
| Small ($0.25 / $1.25) | $0.0183 | $183.50 | $5,505 |
Note where the input goes: the fixed context accounts for 40,800 of the 57,400 input tokens, 71%, even though history is the largest slice of the peak window.
Assumptions and limits
- Uniform turns. Every user message and reply has the same length. Real conversations vary, and one long pasted document changes everything after it.
- Full history, every turn. Nothing is summarized, windowed or dropped, and RAG context is retrieved once and kept for the whole conversation.
- No caching. Every input token is billed at the full input price. Providers that cache a repeated prefix bill it at a discount, which mostly hits the fixed context.
- Three fixed tiers. The prices are illustrative points, not a specific vendor's list. The model's context window is not checked against the peak.
- A 30-day month at constant daily volume.
How to use the result
- Attack the slice that repeats most. The fixed context is billed once per turn, so in a long conversation it is usually the cheapest place to win: a shorter system prompt, leaner tool schemas, fewer RAG chunks or a cached prefix.
- Cap history when turns grow. History cost rises with the square of the turn count, so beyond a few turns a rolling window or a running summary pays for itself.
- Test one lever at a time. Halving RAG context to 1,500 tokens brings the default to $0.1842, 16% less. Comparing levers this way stops you from optimizing the wrong slice.
- Keep peak context well inside the window. Leave room for the reply and for the longest conversations, not the average one.
- Route by difficulty. Each tier down is 3 to 4 times cheaper here, so sending routine turns to a smaller model can beat any prompt trimming.
How it works
- Each turn re-sends system prompt + tools + RAG context + the full history as input.
- Cost = input tokens × input price + output tokens × output price, per 1M tokens.
- Peak context = fixed context + every user message and reply in the conversation.
- Token counts are entered directly; pick one of three price tiers; a month is 30 days.
Frequently asked questions
How is LLM API cost per conversation calculated?
Add up the input tokens of every turn and multiply by the input price per million, then add the output tokens times the output price per million. Input includes everything sent on each turn: the system prompt, tool definitions, retrieved context and the conversation so far. With the defaults, 57,400 input tokens at $3 per million is $0.1722 and 3,200 output tokens at $15 per million is $0.0480, so one 8-turn conversation costs $0.2202.
Why do long conversations cost more per turn?
Because every turn re-sends the fixed context plus the whole history so far. Turn 8 of the default conversation sends 5,100 fixed tokens, eight user messages and seven earlier replies, 9,100 input tokens in all, while turn 1 sends 5,250. The history terms grow with the square of the number of turns, so doubling the default from 8 to 16 turns raises the cost per conversation about 2.5 times, from $0.2202 to $0.5460.
What counts toward the context window?
The system prompt, every tool or function definition, any retrieved documents and the full message history all share one window, along with the reply the model is generating. The planner reports the peak context, which is the fixed context plus every user message and reply in the conversation, and splits it into four colored segments. With the defaults the peak is 9,500 tokens, and history is the largest segment at 46%, ahead of RAG context at 32%.
What is the difference between peak context and total input tokens?
Peak context is the size of the conversation at its largest, which is what has to fit inside the model's context window. Total input tokens is the sum of what was sent on every turn, which is what you are billed for, because the provider processes the whole prompt again on each call. In the default example the peak is 9,500 tokens but the total billed input is 57,400, about six times larger, because the fixed context alone is sent eight times.
Does the planner count tokens from my text?
No. Each slider takes a token count directly, so measure or estimate your own. A common rule of thumb for English prose is about four characters per token, so a 3,600-character system prompt is roughly 900 tokens, while code, JSON and non-English text often take more tokens per character. For billing-grade numbers, run your real prompt, tool schemas and a sample conversation through your provider's tokenizer or token-counting endpoint.
Which price tier should I choose?
The three tiers are fixed price points built into the tool: $3 and $15, $1 and $5, and $0.25 and $1.25 per million input and output tokens. Pick the one nearest your model's list price. Because every tier prices output at five times input, cost scales exactly with the tier: the default conversation costs $0.2202 on the first, $0.0734 on the second and $0.0183 on the third, so each step down divides the bill by 3 and then by 4.