Formula: Prompt Context Budget Calculator
- Inputs: All units, rates, and allowances are entered by the user.
Rounding: Displayed values are rounded for readability; package and item quantities round upward.
See remaining context after allocating prompt components.
Rounding: Displayed values are rounded for readability; package and item quantities round upward.
Everything you entered except the window itself: the system prompt, conversation history, retrieved context, tool definitions and output reserve. In the default those five lines take up 46% of a 128,000-token window, leaving 68,500 tokens. The output reserve is counted on purpose, because space set aside for the reply is not available for prompt content. The window field is the only input that is not subtracted.
Large enough for the longest reply you expect, with some margin. A short classification answer needs very little. A long report or a large block of generated code needs far more. The default holds back 8,000 tokens. Look at the length of real replies from your application and set the reserve a little above the longest you see.
Because the components you entered add up to more than the window. On a window of 32 thousand tokens the default request overflows, and the calculator shows how far over it is. A negative number means the request will not fit as described. Reduce history, retrieval or tools until the remaining figure is zero or above, ideally with some buffer.
No. It uses whatever number you type in the window field. Window sizes differ between models and can change between versions, so take the figure from your provider's current documentation for the exact model you call. The 128,000 default is only a starting example. Type the documented figure exactly, in tokens, rather than a rounded label.
Use a token counter from your model provider, or read the token count returned with each request. Count the full history your application sends, including earlier user messages and earlier replies, plus any formatting your framework adds around them. Estimating from word counts is rough, especially for code or non-English text.
They can. Each tool's name, description and parameter schema goes into the request, and detailed descriptions add up across many tools. The default allows 8,000 tokens for tools. Setting tools to zero on the default inputs drops allocation from 46% to 40%, which shows how much a large tool set can consume.
Only the headroom. The components stay the same size in tokens. Moving the default request from 128,000 to 192,000 tokens raises the remaining budget to 132,500 and lowers allocation to 31%. The prompt does not get cheaper or shorter; there is simply more empty space around it.
It fits on paper but leaves no margin. Real token counts can differ slightly from estimates, and a user may send a longer message than you planned for. A request sitting exactly at the limit may be truncated or rejected. Leave some buffer above zero so small differences do not cause failures. How much buffer suits you depends on how variable your requests are.
Not by itself. Cost depends on the tokens you send and receive, not on the empty space left in the window. A request with 68,500 tokens free still pays for everything else it sends. Use a separate cost or monthly budget calculator to estimate spending from token counts and your provider's prices.
Yes, by running it for several points in the conversation. Enter the history you expect after five turns, then after twenty, and so on. When the remaining budget approaches zero, that is roughly where trimming or summarising older turns needs to start. The calculator only checks one request at a time. Watch history especially, since it is the field that keeps growing.
Per request, at the high end. The window limit applies to each individual call, so an average hides the requests that fail. If your retrieval step sometimes returns far more text than usual, enter that larger figure in the retrieved context field and check that the remaining budget stays above zero. The default 12,000 tokens is only an example of a mid-sized retrieval result.
Six numbers go in and one comes out. The default describes a request sent to a model with a 128,000-token context window. Of that, 1,500 tokens go to the system prompt, 30,000 to earlier conversation turns, 12,000 to retrieved documents, 8,000 to tool definitions, and 8,000 are held back for the model's reply.
Subtract all five from the window and 68,500 tokens are left. The interpretation line puts the same thing another way: 46% of the window is already spoken for. That leaves a little over half the window free for anything else you might want to add, such as more retrieved passages or a longer user message.
The calculator does nothing more than that subtraction. Its value is in making you write down each component separately, because the parts that grow over time are easy to forget when you only look at the latest message.
A good first pass is to fill the fields from one real request your application has already sent, rather than from a design document. Real requests tend to carry extra material that plans leave out, such as formatting wrappers, metadata attached to retrieved passages, or a longer system prompt than the one in the spec. Starting from measured numbers makes the remaining budget a figure you can rely on.
In the default, history is 30,000 tokens, more than every other component combined except the remaining headroom. It is also the one that changes on every turn. Each user message and each reply is appended, so a chat that starts small can climb steadily until it dominates the window.
To see the effect, cut history from 30,000 to 12,000 and leave everything else alone. Allocation falls from 46% to 32%. Set history to zero, as it would be for a single-turn request, and only 23% of the window is used. The system prompt, retrieval and tools stay fixed, so history is where most of the swing comes from.
This is why many applications trim or summarise older turns. The calculator cannot do that for you, but it shows how much room a given trimming rule would free. Enter the history size you expect after trimming and compare the remaining budget with the current figure.
A rough way to plan is to estimate how many tokens a typical turn adds, user message and reply together, and divide the default 68,500 tokens of headroom by that figure. The result is approximately how many more turns the conversation can take before the window is full, assuming nothing else grows. Retrieval that changes from turn to turn makes this less exact, so rerun the calculator at a few points rather than trusting one estimate.
In most systems the context window covers both the input and the generated output. If the prompt fills the window, the model has no room to answer, or its answer is cut short. The output reserve is space you deliberately leave empty so the reply has somewhere to go.
The default holds back 8,000 tokens. If you set it to zero, the remaining budget rises and allocation falls to 40%, but that extra headroom is not really free. Any reply would have to fit into it, so you have only moved the problem.
Set the reserve to the longest reply you realistically expect, plus a margin. For short classification or extraction tasks, a small reserve is enough. For long reports, code generation or multi-step reasoning, the reserve should be generous. The calculator treats the reserve exactly like any other allocation, which is the right way to think about it: it is part of the budget, not an afterthought.
The scenario runs keep every component the same and change only the window.
On a 76,800-token window, the same request leaves 17,300 tokens and 77% of the window is allocated. That is still workable, but a few more conversation turns or a larger retrieval set would use up the margin quickly. On a 192,000-token window, 132,500 tokens remain and allocation is only 31%.
Two things follow. First, the components themselves are fixed in tokens, so a larger window does not shrink them; it only adds headroom. Second, a request that fits comfortably on one window can fail on another. If an application might run against more than one model, check the budget against the smallest window it will meet, not the largest.
Whatever the window, confirm the figure in your provider's documentation for the exact model and version you use. This page does not supply window sizes; it uses whatever you type.
The calculator works in tokens, not words or characters. Tokens are pieces of text as the model's tokenizer splits them, and the ratio to words varies with language, formatting and content. Code, tables and non-English text often take more tokens per word than plain English prose.
The most reliable way to fill in the fields is to measure. Many model providers offer a token-counting tool or return token counts with each request. Run your system prompt, a typical history, a retrieval result and your tool schemas through it, and enter those numbers.
Tool definitions deserve a careful count. Each tool's name, description and parameter schema is sent with the request, and long descriptions add up. In the default, tools take 8,000 tokens, as much as the output reserve. Removing tools a particular request does not need is one of the easiest ways to recover space: with tools at zero, allocation drops to 40%.
Retrieved context is the other variable worth measuring per request rather than guessing. The default 12,000 tokens might be a handful of long passages or many short ones; the count depends on the chunk size your retrieval system uses and how many chunks it returns.
When the counts come from different tools, check they use the same tokenizer as the model you call. Two tokenizers can give noticeably different counts for the same text, and the window limit is enforced using the model's own count.
If the components add up to more than the window, the answer goes below zero. Put the default request on a window of 32 thousand tokens, for instance, and the result is negative, with a message saying how far over the window the allocation is.
A negative number means the request as described will not fit. Depending on the system, it might be rejected, the oldest content might be dropped, or the reply might be truncated. The calculator does not predict which; it only tells you that something has to give.
The fix is to reduce one or more lines until the remaining budget is zero or above. History and retrieval are usually the easiest to cut. The system prompt and tool definitions are often fixed by the application, and shrinking the output reserve just moves the shortfall onto the reply.
A remaining budget of exactly zero is also a warning. It means the window is completely full, with no margin for a slightly longer user message or a tokenizer count that differs from your estimate. Aim for a buffer.
This page answers whether a request fits, not what it costs. A request that leaves 68,500 tokens free still sends every one of the other tokens to the model, and on most paid services input tokens are billed per request.
That matters for history and retrieval in particular. A long conversation history is resent on every turn, so its cost grows with each message even if it still fits. For spend, a separate cost calculator that multiplies tokens by your provider's prices is the right tool.
Fitting in the window also does not guarantee that the model will use everything well. Very long prompts can make it harder for a model to focus on the relevant parts. The budget tells you there is room; it does not tell you how much context is actually useful for the task.
There is a practical reason to leave headroom unused even when it is available. Every token sent adds a little to the time a request takes to process, so a prompt trimmed well below the limit can return faster than one packed to the edge. Space in the window is a ceiling, not a target.
All six fields reject negative numbers, which prevents most typing errors. The window must also be above zero; leave it empty or at zero and the form asks for a context window instead of returning a result. The other five fields can be zero, which is how you model a request with no history or no tools.
Token counts must be whole numbers, and the form refuses decimals. If your measurement comes from an average or an estimate, round it to the nearest whole token before entering it. Rounding up on the components and down on the window gives a slightly cautious answer, which is usually what you want.
Finally, check that every field uses the same unit. Mixing a window figure in thousands with components in single tokens will give a confident but meaningless answer. If the default 128,000 is typed in thousands while the components are in single tokens, every request will appear to overflow by a wide margin.