LeetLLM
My PlanLearnGlossaryTracksPracticeBlog
LeetLLM

Your go-to resource for mastering AI & LLM systems.

Product

  • Learn
  • Glossary
  • Tracks
  • Practice
  • Blog
  • RSS

Legal

  • Terms of Service
  • Privacy Policy

© 2026 LeetLLM. All rights reserved.

Blog
Context WindowsLong ContextBenchmarksInfrastructure+1

The Million-Token Era: What 1M Context Windows Change

Long-context windows help when relationships across a bounded corpus matter. Know what fits, what breaks, how to evaluate effective context length, and when the economics justify using it.

LeetLLM TeamMarch 14, 2026Updated July 14, 202611 min read

A production incident gets harder when you can only read one log excerpt at a time. You keep jumping between traces, deploy notes, alerts, and runbooks, trying to rebuild one story from fragments. Long-context models change that workflow. As of July 14, 2026, Anthropic, OpenAI, Google, and xAI all document 1M-class context routes, but availability, output limits, pricing, caching behavior, and rate limits still differ by model.[1]Reference 1What's new in Claude Sonnet 5https://platform.claude.com/docs/en/about-claude/models/whats-new-sonnet-5[2]Reference 2GPT-5.6 Sol Modelhttps://developers.openai.com/api/docs/models/gpt-5.6-sol[3]Reference 3Gemini 3 Developer Guidehttps://ai.google.dev/gemini-api/docs/gemini-3[4]Reference 4xAI Models and Pricinghttps://docs.x.ai/developers/models

The useful question isn't "can I send a million tokens?" Ask: will the model use those tokens reliably, and are latency and cost acceptable?

Practical decisions reduce to four checks: what fits, what breaks, which benchmarks matter, and when long context should sit behind retrieval instead of replacing it.

How big is a million tokens?

Token counts are abstract, so translate them into product-sized inputs. If tokenization itself is new, our guide to tokenization covers BPE, WordPiece, and SentencePiece first.

A rough planning rule for older English-heavy tokenizers is 1 token ≈ 0.75 English words ≈ 4 characters. Treat that as a first estimate, not a capacity promise. Claude Sonnet 5's tokenizer produces about 30% more tokens than Claude Sonnet 4.6 for the same text, so model migrations can change both cost and how much text fits without changing the advertised window.[1]Reference 1What's new in Claude Sonnet 5https://platform.claude.com/docs/en/about-claude/models/whats-new-sonnet-5

One million token budget map showing emails and runbooks fitting easily, a service slice using meaningful space, and a mature monorepo spilling beyond the window. One million token budget map showing emails and runbooks fitting easily, a service slice using meaningful space, and a mature monorepo spilling beyond the window.
The scale map keeps "one million tokens" concrete: incident threads and runbooks fit comfortably, a service slice consumes meaningful budget, and a mature monorepo can still spill past the window.

The figure's scale examples are order-of-magnitude checks: thousands of incident emails, many runbook bundles, several mid-sized services, but not a mature monorepo. 1M tokens isn't infinite. It can hold a large bounded corpus, not every artifact a company owns. OpenAI describes GPT-4.1's 1,047,576-token window as more than eight copies of the React codebase, which is a helpful scale anchor, not a rule for every repo.[5]Reference 5GPT-4.1 Modelhttps://developers.openai.com/api/docs/models/gpt-4.1[6]Reference 6GPT-4.1 Modelhttps://openai.com/index/gpt-4-1/

These estimates assume English text. Non-Latin scripts, OCR text, code, tables, and logs tokenize differently. For multilingual or code-heavy products, count tokens on the real corpus before promising that "1M tokens" means a fixed number of pages.

The economic picture

Context window size is only half the story. The cost comes from using that context repeatedly.

Long context became a normal model capability, not a free one. Official docs show provider-specific limits, rate tiers, and cache behavior: some models expose 1M-class windows, some routes expose smaller windows, long prompts can move into different price bands, and cached-prefix pricing depends on provider and model.[1]Reference 1What's new in Claude Sonnet 5https://platform.claude.com/docs/en/about-claude/models/whats-new-sonnet-5[2]Reference 2GPT-5.6 Sol Modelhttps://developers.openai.com/api/docs/models/gpt-5.6-sol[7]Reference 7Gemini API Pricinghttps://ai.google.dev/gemini-api/docs/pricing[4]Reference 4xAI Models and Pricinghttps://docs.x.ai/developers/models

Provider1M-class route to verifyPricing checkCache lever
AnthropicClaude Sonnet 5 at 1M input and 128K maximum output[1]Reference 1What's new in Claude Sonnet 5https://platform.claude.com/docs/en/about-claude/models/whats-new-sonnet-5Recount real prompts with the Sonnet 5 tokenizerPrompt caching for stable prefixes[8]Reference 8Anthropic Model Pricinghttps://platform.claude.com/docs/en/about-claude/pricing
OpenAIGPT-5.6 Sol at 1.05M context, up to 922K input and 128K output[2]Reference 2GPT-5.6 Sol Modelhttps://developers.openai.com/api/docs/models/gpt-5.6-solRequests above 272K input use long-context multipliersImplicit caching plus explicit breakpoints; cache writes are billable[9]Reference 9Prompt cachinghttps://developers.openai.com/api/docs/guides/prompt-caching
GoogleGemini long-context route and context-cache support[3]Reference 3Gemini 3 Developer Guidehttps://ai.google.dev/gemini-api/docs/gemini-3Model-specific token price and cache storage costsContext caching for reusable corpora[10]Reference 10Context cachinghttps://ai.google.dev/gemini-api/docs/caching/
xAIModel window, output cap, and rate tier[4]Reference 4xAI Models and Pricinghttps://docs.x.ai/developers/modelsInput, cached input, and output ratesAutomatic prefix caching on matching prompts[11]Reference 11Prompt Cachinghttps://docs.x.ai/developers/advanced-api-usage/prompt-caching

Production check: ask "how often will this path send 200K, 500K, or 900K tokens?" If the answer is "on every user turn," you probably need retrieval, caching, compaction, or batch processing before you need a bigger window.

💡 Key insight: Context length is an input budget, not an accuracy guarantee. Reliability still depends on evidence order, benchmark behavior, latency, cache hits, and cost.

What gets better

Large context windows help when relationships across a bounded input matter. Codebase debugging can keep routes, handlers, configs, tests, and migrations together. Long-running agents keep more tool results and prior failures visible before compaction. Contract review can compare clauses, exceptions, and amendments without lossy summaries. Few-shot extraction can include many examples when pattern quality matters.

Smaller windows force chunk-level passes and synthesis. Seven-figure context lets the model reason over a bounded document set in one call, if latency and cost fit.

Comparison between separately summarized document chunks, which can lose cross-document links, and joint long-context review that preserves original evidence. Comparison between separately summarized document chunks, which can lose cross-document links, and joint long-context review that preserves original evidence.
Independent summaries may drop a cross-document link before synthesis. Joint context keeps originals available for comparison, but still needs grounded reasoning and pays for one larger prefill.

What gets worse

More context creates three production costs: recall risk, latency, and repeated-token spend.

Lost in the Middle

Long-context research shows that models don't pay equal attention to every part of a long prompt. Information in the middle can be harder to recall than information near the beginning or end.[12]Reference 12Lost in the Middle: How Language Models Use Long Contextshttps://arxiv.org/abs/2307.03172 Exact curves vary by model, task, and prompt structure, but the pattern is common enough to design around.

Long prompt recall map with bright edges, a dim middle band, and must-keep evidence placed at the center to show why middle-position facts are easier to miss. Long prompt recall map with bright edges, a dim middle band, and must-keep evidence placed at the center to show why middle-position facts are easier to miss.
The middle band is the risk: evidence can fit inside the prompt but still be easier to miss when it sits far from the instruction edges.

If you bury a critical fact on page 200 of a 400-page prompt, the model may miss it even though the token fits. Long context is a capability, not a prompt strategy. Put must-not-miss rules, task framing, and final instructions near the edges where models tend to use them better.

Prefill latency

Filling a 1M-token context window is slow. Standard attention scales as O(n2)\mathcal{O}(n^2)O(n2) with sequence length, so longer prompts push compute and memory hard even when kernels such as FlashAttention reduce practical overhead.[13]Reference 13Attention Is All You Need.https://arxiv.org/abs/1706.03762[14]Reference 14FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.https://arxiv.org/abs/2205.14135

Most pain shows up in prefill, the pass that ingests the prompt before the first output token appears. Near-full-window prompts fit batch processing, document review, and long-running agents better than latency-sensitive chat.

Repeated-token spend and context rot

Once prompts become large, every retry and follow-up can resend a huge working set. Prompt caching helps when prefixes match, but cache behavior is provider-specific and can't replace prompt budgeting.[8]Reference 8Anthropic Model Pricinghttps://platform.claude.com/docs/en/about-claude/pricing[9]Reference 9Prompt cachinghttps://developers.openai.com/api/docs/guides/prompt-caching[10]Reference 10Context cachinghttps://ai.google.dev/gemini-api/docs/caching/[11]Reference 11Prompt Cachinghttps://docs.x.ai/developers/advanced-api-usage/prompt-caching

Quality can degrade too. Anthropic's context docs call this "context rot," and Chroma's study across 18 models found performance dropping as input length rises even on simple tasks.[15]Reference 15Context windowshttps://platform.claude.com/docs/en/build-with-claude/context-windows[16]Reference 16Context Rot: How Increasing Input Tokens Impacts LLM Performancehttps://research.trychroma.com/context-rot

Use retrieval, ranking, or pre-filtering first. Spend long-context budget on documents that genuinely need joint reasoning.

How to measure: the benchmarks that matter

When a provider claims "1M context window," ask a stricter question: what kind of task stays reliable at that length?

Needle in a Haystack (NIAH)

Needle in a Haystack inserts a short fact into a long distractor document, then asks the model to recover it.[17]Reference 17Needle In A Haystack: Pressure Testing LLMshttps://github.com/gkamradt/LLMTest_NeedleInAHaystack NIAH gives a useful recall floor, but it doesn't prove synthesis. A model can retrieve one fact from page 200 and still fail to compare a contradiction between page 50 and page 350.

Needle-in-a-haystack benchmark sweep showing a hidden fact inserted at multiple prompt depths, then queried and scored as context length grows. Needle-in-a-haystack benchmark sweep showing a hidden fact inserted at multiple prompt depths, then queried and scored as context length grows.
Needle-in-a-haystack tests move one hidden fact through different prompt depths, then ask whether the model can recover that exact fact from the long input.

RULER

RULER expands beyond one hidden fact.[18]Reference 18RULER: What's the Real Context Size of Your Long-Context Language Models?https://arxiv.org/abs/2404.06654 It asks for retrieval, multi-hop tracing, aggregation, and question answering across long inputs. MRCR and GraphWalks add conversation-memory and traversal-style checks.[15]Reference 15Context windowshttps://platform.claude.com/docs/en/build-with-claude/context-windows Together, these benchmarks answer a better question: where does performance start falling apart, not where does the API reject the request?

Long-context benchmark stack with NIAH checking point recall, RULER checking multi-skill long input tasks, and MRCR checking conversation memory. Long-context benchmark stack with NIAH checking point recall, RULER checking multi-skill long input tasks, and MRCR checking conversation memory.
Use benchmark families for different failure modes: point recall, mixed long-input skills, and conversation memory stress different parts of the context window.

Mistake pattern: treating all long-context benchmarks as equivalent. For production, add your own sweep: place evidence at several depths, vary total prompt length, and score the exact task users need.

The technique stack: how models handle long context

Supporting 1M tokens isn't only training on longer sequences. Different techniques sit at different production layers:

TierExamplesMeaning
Common serving defaultsFlashAttention, GQA/MQA, PagedAttention, cache compressionWidely deployed kernel and memory patterns that cut HBM traffic and KV footprint
Position / training methodsRoPE, ALiBi, YaRN, NTK-aware scalingHow models were trained or adapted to longer positions; not every hosted 1M route exposes every method
Research / multi-host systemsRing Attention and related sequence shardingUseful when you own multi-accelerator long-sequence systems; not something every commercial 1M product advertises as its user-facing stack

Hosted 1M routes package some of these choices for you. Don't read the research list as a checklist of co-equal defaults on every product page.[19]Reference 19Ring Attention with Blockwise Transformers for Near-Infinite Context.https://arxiv.org/abs/2310.01889[14]Reference 14FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.https://arxiv.org/abs/2205.14135[20]Reference 20FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision.https://arxiv.org/abs/2407.08608[21]Reference 21RoFormer: Enhanced Transformer with Rotary Position Embedding.https://arxiv.org/abs/2104.09864[22]Reference 22Train Short, Test Long: Attention with Linear Biases Enables Input Length Generalization.https://arxiv.org/abs/2108.12409[23]Reference 23Extending Context Window of Large Language Models via Positional Interpolation.https://arxiv.org/abs/2306.15595[24]Reference 24YaRN: Efficient Context Window Extension of Large Language Models.https://arxiv.org/abs/2309.00071[25]Reference 25GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints.https://arxiv.org/abs/2305.13245[26]Reference 26Efficient Memory Management for Large Language Model Serving with PagedAttentionhttps://arxiv.org/abs/2309.06180

The KV cache is the most tangible cost. It stores keys and values for previous tokens during autoregressive generation. A useful estimate is KV bytes ≈ 2 × layers × tokens × kv_heads × head_dim × bytes_per_value. On a 32-layer decoder with 8 KV heads, head dimension 128, and bf16 cache entries, a 1M-token prompt needs about 131 GB of KV memory for one sequence before allocator overhead.

KV cache equation and optimization path showing fewer KV heads, paged allocation, and lower-precision values attacking distinct memory multipliers. KV cache equation and optimization path showing fewer KV heads, paged allocation, and lower-precision values attacking distinct memory multipliers.
Shared heads and lower precision shrink live KV state; paged allocation packs that state efficiently so fragmentation wastes less memory.

A worked example: tracing an auth bug across services

Suppose login fails after an account moves to a new enterprise plan. You suspect the bug spans services.

Compare the two context paths

Old flow: search for enterprise_plan, retrieve the top three files, and ask for a diagnosis. The model sees the validator and gateway, but misses middleware that transforms plan codes.

Million-token flow: load auth/, accounts/, and middleware/ together. The model sees form -> validator -> middleware transform -> gateway -> session generator, then spots that middleware strips a field the gateway still expects.

The catch: a 400,000-token prefill can take a while. This is better for agent workspaces, batch review, and deep debugging than real-time chat. Use file tags such as <file name="middleware/plan_transform.py">...</file>, keep must-follow instructions at the front, and put the specific question at the end where recency helps.

When to use (and when to avoid) full context

Use full context for one bounded policy, report, contract, fitting codebase slice, or long-running agent workspace. Use RAG (Retrieval-Augmented Generation) first when you're searching many documents, because irrelevant text hurts accuracy. Avoid filling the window for real-time chat unless you can tolerate higher TTFT. For high-volume batch jobs, do price and cache analysis before scaling traffic.

Long context and RAG aren't competing strategies. Use retrieval to filter down to the most relevant content, then use the large context window to include all relevant evidence without truncation.

Diagram showing Candidate corpus docs, logs, code, Retrieve or pre-filter remove irrelevant text, Count tokens real tokenizer, and Pack prompt rules front, question end. Diagram showing Candidate corpus docs, logs, code, Retrieve or pre-filter remove irrelevant text, Count tokens real tokenizer, and Pack prompt rules front, question end.
Candidate corpus docs, logs, code, Retrieve or pre-filter remove irrelevant text, Count tokens real tokenizer, and Pack prompt rules front, question end.

A useful production flow is: retrieve or pre-filter candidate documents, count tokens with the provider tokenizer, put task rules and must-not-miss facts near the front, put the active question and freshest evidence near the end, and preserve stable prefixes so prompt caching can work.

If many requests share the same large prefix, use provider caching instead of resending a cold corpus every time. Anthropic supports prompt caching. GPT-5.6 uses implicit caching by default and also supports explicit breakpoints after stable content, with writes billed at 1.25 times uncached input and reads reported separately. Google exposes context caching, and xAI caches matching prompt prefixes automatically.[8]Reference 8Anthropic Model Pricinghttps://platform.claude.com/docs/en/about-claude/pricing[9]Reference 9Prompt cachinghttps://developers.openai.com/api/docs/guides/prompt-caching[10]Reference 10Context cachinghttps://ai.google.dev/gemini-api/docs/caching/[11]Reference 11Prompt Cachinghttps://docs.x.ai/developers/advanced-api-usage/prompt-caching

⚠️ Common mistake: Reusing a giant cold prompt on every turn. If the prefix is stable, design for caching; if the evidence changes each turn, retrieve and compact before sending it again.

Start with the smallest context window that reliably solves the problem. Scale up when you hit a measured ceiling.

Context-window rules

  • 1M tokens is roughly 750K English words. Think project-scale, not unlimited memory.
  • Stated context length isn't the same as effective context length. Benchmarks and task sweeps tell you how much of the window the model uses well.
  • Placement matters. Put must-not-miss rules, task framing, and final questions at the edges.
  • Cost and latency are architecture problems. Use retrieval, caching, compaction, and batch paths before dumping every artifact into every prompt.
PreviousOpen-Weight vs Closed API LLMs in 2026: The Enterprise Decision FrameworkNextHow to Build an AI Agent from Scratch
Share this article
XFacebookLinkedInBlueskyRedditHacker NewsEmail
References

What's new in Claude Sonnet 5

Anthropic · 2026

GPT-5.6 Sol Model

OpenAI · 2026

Gemini 3 Developer Guide

Google · 2026

xAI Models and Pricing

xAI · 2026

GPT-4.1 Model

OpenAI · 2025

GPT-4.1 Model

OpenAI · 2025

Gemini API Pricing

Google · 2026

Anthropic Model Pricing

Anthropic · 2026

Prompt caching

OpenAI · 2026

Context caching

Google · 2026

Prompt Caching

xAI · 2026

Lost in the Middle: How Language Models Use Long Contexts

Liu, N.F., et al. · 2023 · TACL 2023

Attention Is All You Need.

Vaswani, A., et al. · 2017

FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.

Dao, T., Fu, D. Y., Ermon, S., Rudra, A., & Ré, C. · 2022 · NeurIPS 2022

Context windows

Anthropic · 2026

Context Rot: How Increasing Input Tokens Impacts LLM Performance

Hong, K., Troynikov, A., & Huber, J. · 2025

Needle In A Haystack: Pressure Testing LLMs

Kamradt, G. · 2023

RULER: What's the Real Context Size of Your Long-Context Language Models?

Hsieh, C.-Y., et al. · 2024

Ring Attention with Blockwise Transformers for Near-Infinite Context.

Liu, H., et al. · 2024 · arXiv preprint

FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision.

Shah, J., Bikshandi, G., Zhang, Y., Thakkar, V., Ramani, P., & Dao, T. · 2024

RoFormer: Enhanced Transformer with Rotary Position Embedding.

Su, J., et al. · 2021

Train Short, Test Long: Attention with Linear Biases Enables Input Length Generalization.

Press, O., Smith, N. A., & Lewis, M. · 2022 · ICLR 2022

Extending Context Window of Large Language Models via Positional Interpolation.

Chen, S., et al. · 2023

YaRN: Efficient Context Window Extension of Large Language Models.

Peng, B., et al. · 2023

GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints.

Ainslie, J., et al. · 2023 · EMNLP 2023

Efficient Memory Management for Large Language Model Serving with PagedAttention

Kwon, W., et al. · 2023 · SOSP 2023