Context Window
Context window
A context window is the maximum number of tokens a large language model (LLM) can take into account in a single request, counting both the input and the output it generates. Everything in the request counts toward it, including system instructions, earlier conversation turns, attached documents and the response itself.[7] Its size sets how much of a long document or codebase the model can work with at once.[1]
What does Context Window mean in simple terms?
Think of the context window as the amount of material an AI can keep spread out in front of it during one conversation. It is measured in tokens, the small pieces of text a model actually reads; one token can be a whole word or only part of one, depending on the language and the model.[8] Google describes the context window as the model's short-term memory: it can only hold a limited amount at a time.[1] When a conversation or a document goes past that limit, the request may be rejected, or the oldest messages may be dropped or summarized.[7] That is why it is one of the first numbers to check before using AI on long reports, contracts or code.
How can Context Window be explained with an analogy?
It is the size of the desk you can spread your documents on during a single meeting.
Where is Context Window used?
Google Gemini 1.5 Pro — A million-token window
In February 2024 Google announced Gemini 1.5 Pro. Its standard window was 128,000 tokens, and a limited group of developers and enterprise customers could test a window of up to 1 million tokens in private preview.[8] Google said this was enough for about 1 hour of video, 11 hours of audio, codebases with over 30,000 lines of code, or over 700,000 words.[8] In June 2024 Google opened a 2-million-token window on Gemini 1.5 Pro to all developers and introduced context caching in the Gemini API to lower the cost of reusing the same tokens across prompts.[5] Google's documentation notes that question answering over large material used to be practical mainly through retrieval-augmented generation (RAG), and long context now allows more of the material to be passed in directly.[1]
Result: Window extended from 32,000 tokens (Gemini 1.0) to up to 1 million tokens in production testing (Google, February 2024).[8]
Anthropic Claude 2.1 — Asking questions about a 500-page document
Anthropic released Claude 2.1 in November 2023 with a 200,000-token context window, double the previous limit. The company said this equals roughly 150,000 words, or over 500 pages, so users could upload whole codebases, financial filings such as S-1s, or long literary works and ask for summaries, Q&A and comparisons.[2] Anthropic said tasks that would typically take hours of human effort might take Claude a few minutes, and expected latency to fall as the technology improved.[2] In the claude.ai chat app, the full 200K window was initially reserved for Pro users.[2]
Result: Context window doubled to 200,000 tokens, about 500 pages (Anthropic, November 2023).[2]
xAI Grok 4 Fast — A 2-million-token window at low unit prices
xAI announced Grok 4 Fast on September 19, 2025. It was released to the API as two models, grok-4-fast-reasoning and grok-4-fast-non-reasoning, each with a 2-million-token context window.[3] Launch pricing for input was USD 0.20 per million tokens for requests under 128,000 tokens and USD 0.40 per million at or above that size.[3] xAI also claimed a 98% reduction in the price of reaching the same benchmark performance as Grok 4, based on its own analysis.[3]
Result (company-reported): 2-million-token window; launch input price USD 0.20 per million tokens below 128K.[3]
Research — Longformer and the cost of long inputs
In 2020, Iz Beltagy and colleagues at the Allen Institute for AI published Longformer. The paper pointed out that standard self-attention scales quadratically with sequence length, which made long inputs hard to process, and proposed an attention mechanism that scales linearly so that documents of thousands of tokens or more become practical.[6] The pretrained Longformer consistently outperformed RoBERTa on long-document tasks and set new state-of-the-art results on WikiHop and TriviaQA.[6] It is one of the research lines that showed long inputs could be handled more efficiently.
Result: Attention cost growing linearly instead of quadratically with input length.[6]
Try it today
- Look up the context window of the model you use in its official documentation.[1][7]
- Translate the number into something tangible: 200,000 tokens is roughly 500 pages of English text, and 1 million tokens is about 50,000 lines of code or 8 average-length English novels.[1][2]
- Measure how many tokens your own documents use with the provider's token counting tool, since the count differs by language and tokenizer.[7]
- Load one full report or contract (with sensitive details removed) and ask for a summary and a list of open issues. Put your question at the end, after the material.[1]
- Compare the result and cost with a RAG setup that sends only selected passages.[1]
- If you query the same long material repeatedly, check whether context caching or prompt caching is available.[1][7]
Limits and direction
A bigger window does not guarantee better answers. Google's documentation says Gemini can reach about 99% accuracy when looking for a single "needle" in a long text, but accuracy drops when several pieces of information must be found, and longer inputs generally increase the time to the first token.[1] You also pay for the input tokens every time you resend the same material.[1] Anthropic's documentation describes "context rot": as the token count grows, accuracy and recall degrade, so choosing what goes into the context matters as much as how much fits.[7] The RULER benchmark found that although all 17 tested models claimed windows of 32,000 tokens or more, only half kept satisfactory performance at 32,000 tokens.[9] Earlier research also found that models often use information at the beginning or end of a long input better than information in the middle.[10]
Windows have grown quickly: 2,048 tokens for GPT-3 (2020), 32,768 for a limited GPT-4 version (March 2023), 100,000 for Claude (May 2023), 1 million for Gemini 1.5 Pro in preview (February 2024), and 2 million for Gemini 1.5 Pro (June 2024) and Grok 4 Fast (September 2025).[13][12][11][8][5][3] Pricing is changing too. In March 2026 Anthropic made the 1-million-token window for Claude Opus 4.6 and Sonnet 4.6 generally available at standard pricing, removing the long-context premium.[4] On the usage side, caching is becoming a standard way to cut costs: Google says that for Gemini Flash, the per-request input/output cost on cached content is about 4 times lower than the standard rate, with storage billed per hour. This is the guide's example rather than a price guarantee; check current model-specific caching and output rates.[1] For long conversations and agents, providers also offer server-side compaction, which summarizes earlier parts of a conversation so work can continue past the limit.[7] A practical habit is to check three things together: the window size, how well the model performs at long lengths, and the caching price.
How has Context Window evolved?
Which concepts are related to Context Window?
- FoundationTokenThe context window is measured in tokens.[8]
- Related conceptMax TokensThe parameter that caps output length; output also counts toward the window.[7]
- Next stepPrompt CachingCuts cost when the same long context is reused; cached tokens still occupy the window.[1][7]
- Alternative approachRAGRetrieves only relevant passages when the full material does not fit or costs too much.[1]
Long Context vs RAG
Which sources explain Context Window?
- Google AI for Developers — Long context, Gemini API docs (checked 2026-10-14) — https://ai.google.dev/gemini-api/docs/long-context
- Anthropic — Introducing Claude 2.1 (2023-11-21) — https://www.anthropic.com/news/claude-2-1
- xAI — Grok 4 Fast (2025-09-19) — https://x.ai/news/grok-4-fast
- Anthropic (Claude blog) — 1M context is now generally available for Opus 4.6 and Sonnet 4.6 (2026-03-13) — https://claude.com/blog/1m-context-ga
- Google Developers Blog — Gemini 1.5 Pro 2M context window, code execution and Gemma 2 (Korean edition, 2024-06-27) — https://developers.googleblog.com/ko/new-features-for-the-gemini-api-and-google-ai-studio/
- Beltagy, Peters, Cohan — Longformer: The Long-Document Transformer (arXiv 2004.05150, 2020-04-10) — https://arxiv.org/abs/2004.05150
- Anthropic — Context windows, Claude Platform Docs (checked 2026-10-13) — https://platform.claude.com/docs/en/build-with-claude/context-windows
- Google — Our next-generation model: Gemini 1.5 (2024-02-15) — https://blog.google/innovation-and-ai/products/google-gemini-next-generation-model-february-2024/
- Hsieh et al. — RULER: What's the Real Context Size of Your Long-Context Language Models? (arXiv 2404.06654, 2024-04-09) — https://arxiv.org/abs/2404.06654
- Liu et al. — Lost in the Middle: How Language Models Use Long Contexts (arXiv 2307.03172, 2023-07-06) — https://arxiv.org/abs/2307.03172
- Anthropic — Introducing 100K context windows (2023-05-11) — https://www.anthropic.com/news/100k-context-windows
- OpenAI — GPT-4 (2023-03-14) — https://openai.com/index/gpt-4-research/
- Brown et al. — Language Models are Few-Shot Learners (GPT-3 paper, arXiv 2005.14165, 2020) — https://arxiv.org/abs/2005.14165
Tell us what you think
Your feedback helps us improve the content.