A context window is the maximum text, in tokens, an AI model can use at once. Learn how it works, its limits and why it matters for AI search.

On this page
Summary
A context window is the maximum amount of text, measured in tokens, that a language model can use in one request. It includes the instructions, the conversation history, any retrieved documents and the reply itself, so anything beyond the limit is dropped or summarized.
Want to go further? Ask
Context window is the working memory of a large language model (LLM). Everything the model reads or writes for one response has to fit inside it, and information outside the window is invisible to the model for that request.
A context window is the complete set of text a model can refer to when it generates a response, including the response itself. Anthropic's context window documentation describes it as a working memory for the model, which is different from the large body of data the model learned during training. Everything in the window counts: the system instructions, the user message, earlier turns, retrieved passages and the answer being written.
Each turn adds to the window, so the input keeps growing as a conversation continues. In Anthropic's illustration, every user message and every response stays in the input of the next turn, which is why a long chat reaches the limit sooner than a short one. Chat interfaces can also drop the oldest messages first, on a rolling first in, first out basis, which is why an assistant can seem to forget the start of a long discussion.

The diagram shows the principle clearly: the input of turn three contains everything from turns one and two, and the total must stay within the window's budget. Once that budget is used up, something has to give, either older messages are removed or they are compressed into a summary.
The window is measured in tokens, not in words or characters. A token is a unit of text produced by the model's tokenizer, and it can be a whole word, a fragment of a longer word or a punctuation mark. The number of tokens depends on the tokenizer and on the language, so the same paragraph often takes a different number of tokens in English than in another language.
This matters in practice because long documents, code and pasted logs fill the window faster than their word count suggests. A short question with a long attachment can use most of the budget before the model has started to answer.
Window sizes are advertised maximums, and they have grown quickly. The table below summarizes what two major providers state in their documentation at the time of writing.
| Model family | Stated context window | Where it is stated |
|---|---|---|
| Claude (Anthropic) | Up to 1M tokens, depending on the model | Anthropic context window documentation |
| Gemini (Google) | 1M tokens or more for many models | Gemini API long context documentation |
Google's long context documentation for Gemini explains that many Gemini models come with a window of one million tokens or more, which lets developers send whole codebases or long transcripts in one request. Other providers and open models offer different sizes, so check the documentation of the exact model you use before you design a workflow around its limit.
Not automatically. A larger window lets you fit more text, but the model does not use all of that text equally well. In a 2023 paper, Liu and colleagues found that performance is often highest when the relevant information sits at the beginning or the end of the input, and that it degrades significantly when the same information sits in the middle of a long context, even for models built for long contexts. Researchers call this the lost-in-the-middle effect.
Anthropic's documentation makes the same point in practical terms: as token count grows, accuracy and recall degrade, a phenomenon it calls context rot. The lesson is to curate what enters the window, not to fill it because it is available.
Most production systems do not rely on a large window alone. Retrieval augmented generation fetches only the passages that match the question and places them in the prompt, which keeps the window small and focused. Other methods include summarizing older turns, trimming long tool outputs and keeping standing instructions short. Anthropic describes server-side compaction, which summarizes earlier parts of a conversation, as the primary strategy for long-running and agentic workflows.
For SEO and generative engine optimization, the context window is the space your content competes for inside an AI answer. When an assistant retrieves sources, only part of each page fits into its window, so a passage that answers the question in its first sentences is more likely to be used than a page padded with filler. This is the logic behind content chunking: self-contained sections that a retrieval system can lift out whole and place in a limited budget.
Writing for this constraint means putting the answer first, keeping each section focused and removing text that adds no information, the same habits described in LLM ready content. To check how easily an assistant can extract answers from one of your pages, try Sorank's free LLM readability checker. For a broader view of becoming a source that AI assistants cite, read our guide to getting cited by AI assistants.
A context window is the working memory of a language model, the total text, measured in tokens, that it can use to write one reply. It is bounded, and it is imperfect: accuracy degrades as the window fills, and information in the middle of a long input is easily missed. Write compact, answer-first passages that remain useful when a retrieval system pulls them into a limited window, and your content has the best chance of being read and cited.
Sources
It is the maximum amount of text, measured in tokens, that a model can use in one request. It includes the instructions, the conversation history, retrieved documents and the reply itself.
No. A larger window lets you fit more text, but models do not use all of it equally well. Information placed in the middle of a long input is often missed, so what you put in front of the model matters more than its size.
When an assistant answers a question, only part of each retrieved source fits in its window. Concise, well-structured passages that answer the question directly are more likely to be used and cited than padded text.
