Context Window Calculator
Budget prompt, reserved, and completion tokens against a model window.
About this tool
Enter the model's context window and what you plan to use: prompt tokens (or paste the prompt to have them counted), tokens reserved for the system prompt and tools, and the completion budget. You get tokens remaining, utilization and a fits yes/no.
How to use
How it works
Everything in a request shares one window: remaining = window − prompt − reserved − completion. If the result is negative, the request does not fit and the tool says by how many tokens. Pasted prompt text is counted with the o200k_base tokenizer and overrides the prompt tokens number.
remaining = window − prompt − reserved − completion
Worked example
A 128k model
- Input
- Window 128,000; prompt 1,200; reserved 1,000; completion 2,048
- Output
- 123,752 tokens remaining; utilization 3.3%; fits: yes
- Walkthrough
- 1,200 + 1,000 + 2,048 = 4,248 tokens allocated. With a 130,000-token prompt the result is -5,048 and Fits reads no (over by 5048).
Limitations
- It does not know any model's real window; you type it in.
- Pasted text is counted with o200k_base, which is approximate for non-OpenAI models.
- Hidden overhead, such as chat formatting tokens and tool schemas, is not added; put it in reserved tokens.
Questions
How do I know if my prompt fits in the context window?
What should I reserve?
Does the completion count against the window?
Can it count my prompt for me?
Features
- Remaining and utilization
- Counts pasted text
- Over-by message
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Machine Learning for Everybody
freeCodeCamp.org
Accessible ML survey for AI calculator and metric tools.
Watch on YouTubeBig-O Notation in 100 Seconds
Fireship
Complexity intuition when estimating training/inference cost.
Watch on YouTube
- DeepLearning.AI
DeepLearning.AI
Courses and explainers for modern AI tooling.
- Hugging Face docs
Hugging Face
Model hub docs next to tokenizer and embedding helpers.