LLM Context Windows Explained: Tokens, Limits and Long Documents
A context window is the text a language model can hold at once, measured in tokens. Learn the limits of GPT, Claude and Gemini, and handling long documents.
By Galactic News Editorial · Published 2026-11-25T20:15:22+00:00 · Updated 2026-11-25T20:15:22+00:00
LLM Context Windows Explained: Tokens, Limits and Long Documents
A context window is the amount of text a language model can hold in mind at once. It is measured in tokens. When the window fills up, the model cannot see the oldest material any more. This guide explains tokens, the limits of the main models, and how to work with long documents without hitting the wall.
The short version: a token is roughly three quarters of an English word. A 128,000-token window holds about 96,000 words, or roughly 300 pages. A 1,000,000-token window holds about 750,000 words. The window is shared between your input and the model's output. Everything you send and everything it writes comes out of the same budget.
LLM context windows explained: tokens, limits and long documents
Start with tokens. Models do not read words. They read tokens, which are chunks of text produced by a tokenizer. Common words are often one token. Rare words split into several. Code and non-English text use more tokens per word. OpenAI's GPT-4o uses a tokenizer called o200k_base, with a vocabulary of 200,000 token identifiers.
A useful rule is that one token is about four characters of English text, or about 0.75 words. So 1,000 tokens is roughly 750 words. These are estimates. The only exact count comes from running the text through the model's tokenizer. OpenAI's tiktoken library does this for its models.
The context window is the total budget for one request. It covers the system instructions, the conversation history, any files you attach, tool definitions, and the model's reply. Input and output share the same pool. If your prompt uses 115,000 tokens of a 128,000-token window, the model can only write about 13,000 tokens back.
The limits of the main models
Context windows have grown fast. The frontier is now around one million tokens. Six of the seven major vendors offer it on their flagship models. The numbers below come from vendor documentation checked in October 2026.
| Model | Context window | Max output | Notes |
|---|---|---|---|
| GPT-4o | 128,000 tokens | 16,384 tokens | Deprecated October 2026; snapshots shut down January 2027 |
| GPT-4.1 | 1,047,576 tokens | 32,768 tokens | Deprecated; shuts down January 2027 |
| Claude (baseline) | 200,000 tokens | Varies by model | About 500 pages of text; standard across Claude 3.5 and 3.7 |
| Claude flagship (Sonnet 5.5, Opus 5.5) | 1,000,000 tokens | 128,000 tokens | Paid plans; some tiers need usage credits enabled |
| Gemini (current models) | 1,048,576 tokens | Varies | Google lists 1,048,576 across current Gemini models |
Two details matter more than the headline number. First, the output limit is separate and much smaller. A model with a million-token window may still write only 128,000 tokens in one reply. Second, some vendors charge more once a prompt passes a threshold. Claude Haiku 5.5 charges more above 100,000 tokens. Gemini and Grok have thresholds at 200,000. OpenAI's GPT-6 family has one at 272,000. Check the pricing page before sending a very long prompt.
What happens when the window fills up
Each product handles a full window differently. In an API call, the request simply fails. OpenAI returns an HTTP 400 error with a context length message. Anthropic returns an invalid request error. Your code must catch that error and do something about it.
In chat products, the behaviour is friendlier. Claude automatically summarises earlier messages to make room for new ones when a conversation approaches the limit. This is called compaction. ChatGPT compresses or drops older details. The model keeps working, but it may forget the exact wording of something from early in the conversation.
Compaction is not memory. Nothing carries into a new session. A new chat starts with an empty window, whatever you discussed yesterday. Long projects need a file or a document store outside the chat.
Working with long documents
Most real work with long documents follows one of four patterns. Pick the pattern that matches the job.
- Put the whole document in the prompt. This works when the document fits comfortably, with room left for the answer. Keep the document under about 70% of the window. The rest is for instructions and output. This is the simplest option and the best one when it fits.
- Chunk and summarise. Split a long document into sections. Summarise each section. Then work from the summaries. This handles documents far larger than any window. The cost is detail: a summary drops nuance, and the model cannot quote what it never saw.
- Retrieve only what matters. Index the document and fetch the relevant passages for each question. This is retrieval-augmented generation, or RAG. It scales to very large document sets. It needs infrastructure, and it can miss passages that matter if the search is weak.
- Cache the repeated parts. If the same long document is sent in many requests, prompt caching stores it once and reuses it. Anthropic's caching needs a minimum prefix, 1,024 tokens for Sonnet and Opus, and 2,048 for Haiku. Caching cuts cost and latency on repeated prompts.
For a single document under about 100,000 tokens, the whole-document approach is usually best. The model sees everything, and you avoid the failure modes of chunking and retrieval. Above that size, chunking or retrieval becomes the practical choice.
Counting tokens before you send
Never guess a document's token count. Count it. OpenAI's tiktoken library counts tokens for its models. Anthropic's API returns token counts for messages. Most chat products show an estimate, but the exact number comes from the tokenizer.
Watch the hidden consumers too. System instructions, tool definitions and conversation history all spend tokens. In an agent loop, tool outputs can quietly eat the budget. Log the token count of each request while you develop. A request that works in testing can fail in production when the history grows.
Bottom line
A context window is a shared budget for input and output, measured in tokens. A token is about three quarters of a word. Flagship models now offer around one million tokens, but the output limit stays far smaller, and long prompts can cost more. For long documents, put the whole file in the prompt when it fits, and switch to chunking, summarising or retrieval when it does not. Count tokens before you send, and remember that a new session starts empty.