Free tool · No signup

LLM Context Window Budget Calculator

Work out how much room is left for your next request. Budget your prompt, history, tools, and retrieved context while leaving space for the model’s reply.

Plan your request

Updates as you type

Start with this example, then replace the numbers with your own token counts.

Token budget inputs

Use the token limit for your model and provider endpoint.

01 / Input tokens

System and developer messages.

Earlier messages and the prompt you will send.

Definitions, schemas, and results sent with this request.

RAG passages, documents, or security references.

Count each token once. Include image or document tokens in the relevant category.

02 / Leave room

Room for the reply, including reasoning where applicable.

Percentage of the entire context window. 5% is a starting example.

Share this budget

The link includes only these numbers. Anyone with the link can read them; it does not contain prompts or provider keys.

Your numbers stay in your browser. No model calls or account required.

Your context budget

Within your budget

79,408

tokens still available for more context

38% allocated128,000 total
Input
34,000 tokens
Output reserve
8,192 tokens
Safety margin
6,400 tokens
Available
79,408 tokens

You can budget another 79,408 input tokens while keeping your chosen output reserve and safety margin.

A planning estimate, based on your counts. Separate provider input/output limits and request overhead can reduce usable space.

Need security context for your AI workflow? CyberRouter adds relevant references using your models and provider keys.

Explore CyberRouter

How to budget an LLM context window

01 /

Check your endpoint

Use the context-window limit for the exact model and provider you will call. Advertised limits can differ across endpoints.

02 /

Add what you will send

Include instructions, chat history, the current prompt, tool schemas and results, and retrieved documents. Each token belongs in one category.

03 /

Reserve room to reply

Set aside output tokens and a margin for uncertainty. The calculator shows the remaining input budget or how far your plan exceeds the window.

The context budget formula

Remaining tokens = context window − input tokens − output reserve − safety margin. The safety margin is your chosen percentage of the full context window, rounded up.

Worked example · 128,000-token window

128,000 − 34,000 − 8,192 − 6,400
= 79,408 tokens available

34,000 input tokens = 2,000 instructions + 12,000 conversation + 4,000 tools + 16,000 retrieved context. The 5% margin reserves 6,400 tokens.

Try a worked context budget

Context budget questions

How do I calculate my remaining context budget?

Start with your endpoint’s context window. Subtract system instructions, conversation and current prompt, tool definitions and results, and retrieved material. Then subtract your output reserve and safety margin. The remainder is the space you can budget for more input. Count each token only once across the input categories.

Is this an exact token counter?

No. This tool calculates a budget from token counts you enter; it does not tokenize text or call a model. Get counts from your provider’s tokenizer, token-counting endpoint, or request usage. Tokenization varies by model, and images, documents, message formatting, and tool schemas can add overhead. The default numbers are an editable example, not a model specification.

Does the output use the same context window?

Many LLM endpoints budget input and generated output within a shared context window. Reserve room for the full generation, including reasoning tokens where your provider counts them. A model can also have separate input and output limits; this calculator does not validate those endpoint-specific caps. Check your provider’s documentation before sending the request.

Do cached tokens and RAG documents still take up space?

Count cached input that is present in the model’s context, along with retrieved documents and tool results you actually send. A cache discount does not make those tokens disappear from the context window. For RAG, budget the selected passages included in this request, not the size of your full document collection.

What safety margin should I use?

The example reserves 5% of the full window, rounded up to a whole token. That is an adjustable planning choice, not a universal recommendation. Increase it when token estimates are uncertain or a workflow may add tool results. Use counts and usage from your own requests to decide how much room to leave.

What should I do when the budget is exceeded?

Reduce repeated instructions, summarize older messages, retrieve fewer passages, or shorten tool output. You can also adjust the output reserve if a shorter answer is suitable, or select an endpoint with a larger context window. The over-budget result shows how many tokens you need to remove to meet the plan you entered.

Can I use this with CyberRouter or another LLM gateway?

Yes. Enter the context limit of the model endpoint you use. For CyberRouter, include added security references in the retrieved-context field, then allow for your conversation, tools, and output. The same calculation can help plan other LLM and RAG workflows. The calculator is free, requires no signup, and keeps your entered numbers in your browser.

For a provider-specific explanation of shared context, tool tokens, and caching, see Anthropic’s context-window documentation. Check your chosen endpoint’s rules when planning a request.

Accessibility

Adjust how CyberRouter looks and moves. Preferences apply to this browser.

You can also use your browser’s zoom controls.

Accessibility help

Analytics preferences

Choose anonymous page counts or optional visit, scroll and reading-time analytics. Privacy details.