Context Window Size: 128K vs 256K vs 1M, Cost and Recall Test

Blog / Model watch

Context Window Size: 128K vs 256K vs 1M, Cost and Recall Test

For most tasks, a bigger context window is not automatically better. The context window is the maximum number of tokens a model can handle in a single request, and both input and output count against it. A larger window lets you fit more in, but every extra token is billed, the time to first token grows, and the model may not reliably use information buried in the middle. To choose between 128K, 256K and 1M, first ask whether the task needs the model to "see" all the material at once, then decide how much you are willing to pay per request and how long you are willing to wait.

Below, we first clear up a few easily confused concepts, then give a table for picking a window by task, and finally a method for testing recall yourself, which you can rerun whenever you switch models or providers.

What does the context window actually include?

A single API request's context window usually holds all of the following at once:

  • the system prompt;
  • tool or function definitions (agent-style tools may register dozens of tools, and the definitions alone take up a lot of tokens);
  • the full conversation history, including earlier tool call results;
  • your input for this turn, such as pasted files or retrieved snippets;
  • the output the model generates this turn, including the reasoning trace for reasoning models.

So "1M context" does not mean you can put 1M tokens of documents in. Input plus the reserved output length cannot exceed the window, and many APIs also set a separate maximum output length that is much smaller than the window. When you go over, some APIs return a 400 error outright, while some clients silently drop the oldest messages. The latter raises no error, but the model quietly "forgets" what came earlier.

How each part of the input is billed, and why multi-turn conversations get more expensive the longer they run, is broken down item by item in How LLM token billing works, so we won't repeat it here.

What are the advertised context windows of mainstream models?

cdnping's model monitoring page collects data from OpenRouter's public model catalog. In the 2026-10-17 data snapshot, the advertised context windows of the 16 key model entries we track are distributed as follows:

Advertised context (tokens)Entries
262,144 (about 256K)1
500,0002
1,000,0005
1,048,5766
1,050,0002

In other words, 13 of the 16 are around 1M, and the rest fall into the 256K and 500K tiers. None of these key models has a 128K entry, but some self-hosted models, lightweight models and older endpoints are still at 128K, and client tools may also cap the usable window below the model's advertised value.

Two caveats: this is only a sample of key models and does not represent the whole catalog, and cdnping only started collecting data on 2026-10-17, so the data window is very short. Model launches, removals and price changes are recorded on the model monitoring page, and changes to vendors' official changelogs and pricing pages can be found in Official site changes.

If a model advertises 1M, can it use 1M well?

Not necessarily. The advertised window says "this much fits without an error"; effective recall says "once it is in there, can the model accurately find and use it". Common differences include:

  • Information at the beginning or end is usually easier for the model to use than information in the middle.
  • Finding a single fact and combining facts scattered across several places to reason are very different levels of difficulty.
  • The same model can behave differently on long inputs when served by a different inference provider or at a different quantization precision (see Did the model get dumber, or did the provider change?).

There is no universal number to apply to any of this. The most reliable approach is to test with your own material at the lengths you will actually use, and the steps are given below.

How much slower is the first token with long input?

Before generating the first token, the model has to process the entire input (prefill). The longer the input, the longer this step takes, and what the user sees is "nothing appears for a long time after sending the request". This time has nothing to do with the network, so switching routes will not help.

When troubleshooting slowness, separate this from network latency. cdnping's online speed test measures the initial connection and round-trip time to each vendor's API endpoint, so it reflects only the network portion. If the network round trip is normal and short requests are fast, but stuffing in a long document makes you wait a long time, the problem is most likely prefill. For how to break latency into its parts, see AI API latency breakdown: connection setup, gateway round trip and time to first token.

The practical way to measure it is simple: with the same model and the same question, send requests with different amounts of material, use a streaming API, and record the time from sending the request to receiving the first token. The self-test script below prints this value as well.

How much more does long context cost?

Input is billed per token, so filling the window once means paying for a full input once. Based on the list prices in OpenRouter's model catalog in the same snapshot, the input price of these 16 entries ranges from 0.1 to 4 USD per million tokens, and the output price from 0.47 to 12 USD per million tokens.

Here is a worked example (illustrative only). Suppose the input price is 2 USD per million tokens and one request carries 800K tokens of material. The input cost for that single request is 1.6 USD. In a multi-turn conversation, every turn sends that material again, so the cost grows linearly with the number of turns. For the same question, if you first retrieve the most relevant 20K tokens and then ask, the input cost per request is 0.04 USD.

A few ways to reduce long-context cost:

  1. Use prompt caching for fixed prefixes. Put the system prompt, tool definitions and large documents you cite repeatedly at the very start and keep them unchanged; on a cache hit you are billed at the cache price. For the exact conditions, see How to use Claude API prompt caching to save money.
  2. Route by task. Send tasks that need to read all the material to a long-window model, and send short tasks such as completion and classification to a cheaper model. See How to do multi-model routing.
  3. Include input volume when comparing prices. Looking only at unit price makes it easy to miscalculate; in long-input scenarios the input price often affects the total bill more than the output price. See How to compare LLM API prices.

How do you choose a context window by task?

TaskWindow typically neededSuggested approach
Everyday Q&A, editing a piece of code128K is enoughLimit the number of turns; start a new session when it gets too long
Reading a full contract, paper or long reportAround 256K is usually enoughPut the whole document in, with the question after the material
Editing code across multiple files, long agent tasks256K-1MLet tools read files on demand; don't dump the whole repository in at once
Analyzing an entire code repository or several books at once1MTest recall first to confirm that information in the middle can be used
Enterprise knowledge base, documentation site Q&ANot solved by window sizeUse retrieval-augmented generation (RAG) and include only the relevant snippets each time
Long-running multi-turn conversations, customer supportNot solved by window sizeSummarize history periodically and keep the summary instead of the full text

To judge whether the window is big enough, first look at how large your real inputs are. Record usage.prompt_tokens (input_tokens in the Anthropic format) from several real requests, take the maximum, and add the output length you reserve. Don't estimate from character counts; the token conversion rate differs a lot between Chinese, code and English.

How do you test a model's long-context recall yourself?

The idea is "needle in a haystack": insert several marker facts at different positions in a long block of filler text, then ask a question and see whether the model answers correctly. The script below works with any OpenAI-compatible API.

Step 1: Set the environment variables.

export BASE_URL="https://your-api-endpoint/v1"
export API_KEY="your-api-key"
export MODEL="model-name-to-test"

Step 2: Save and run the script. For the filler text, we recommend using material from your real workload (for example, a sanitized document), which reflects actual conditions better than random text.

# recall_test.py  Usage: python3 recall_test.py filler.txt 200000
import os, sys, time, json, random, urllib.request

filler = open(sys.argv[1], encoding="utf-8").read()
target_chars = int(sys.argv[2])            # number of characters of filler text
while len(filler) < target_chars:
    filler += filler
filler = filler[:target_chars]

positions = [0.1, 0.3, 0.5, 0.7, 0.9]      # insertion positions (fraction of the full text)
needles = {}
text = filler
for p in sorted(positions, reverse=True):
    code = f"{random.randint(100000, 999999)}"
    needles[p] = code
    i = int(len(text) * p)
    text = text[:i] + f"\n【标记 {int(p*100)}】本段的校验码是 {code}。\n" + text[i:]

question = "请按标记编号列出文中出现的所有校验码,格式:编号: 校验码,每行一个。"
body = {
    "model": os.environ["MODEL"],
    "messages": [{"role": "user", "content": text + "\n\n" + question}],
    "stream": True,
    "stream_options": {"include_usage": True},
}
req = urllib.request.Request(
    os.environ["BASE_URL"].rstrip("/") + "/chat/completions",
    data=json.dumps(body).encode(),
    headers={"Authorization": "Bearer " + os.environ["API_KEY"],
             "Content-Type": "application/json"})

t0 = time.time(); ttft = None; answer = ""; usage = None
with urllib.request.urlopen(req, timeout=600) as r:
    for line in r:
        line = line.decode().strip()
        if not line.startswith("data:") or line == "data: [DONE]":
            continue
        chunk = json.loads(line[5:])
        if chunk.get("usage"):
            usage = chunk["usage"]
        for c in chunk.get("choices", []):
            delta = c.get("delta", {}).get("content") or ""
            if delta and ttft is None:
                ttft = time.time() - t0
            answer += delta

print("输入 token:", usage and usage.get("prompt_tokens"))
print("首 token 等待:", ttft and f"{ttft:.1f}s")
for p, code in needles.items():
    print(f"位置 {int(p*100)}%:", "命中" if code in answer else "未命中")

Note that the needle text, the question and the printed labels in the script are in Chinese. "标记" means "marker", "校验码" means "check code", "命中" means "hit" and "未命中" means "miss". They are left unchanged so the script behaves exactly as tested, and the output reads "hit" or "miss" for each position. If your filler text is in English, you may want to translate these strings, but rerun the test after doing so, since results can vary with the language of the prompt.

Step 3: Repeat at different lengths. For example, run it three times each at 50K, 200K, 500K and 800K characters, and record the input tokens, time to first token and hit/miss results for each run in a table:

Input tokensTime to first token10%30%50%70%90%
(fill in)

Step 4: Read the results. Look at three things: at what length misses start to appear; whether the misses are concentrated in the middle positions; and whether the growth of time to first token with length stays within what you can accept. The length at which recall starts to become unstable is this model's "effective context" in your scenario, and in real use it is best to leave some headroom.

A few notes:

  • Every run is billed by input tokens, and a single run at full length is not cheap, so confirm the script works at a small length first.
  • This test only checks "finding a single fact", which is the simplest case. If your task needs reasoning across paragraphs, change the question so that answering requires combining two of the check codes.
  • Results for the same model name can differ between providers, so record the API endpoint when you test.
  • When the input exceeds the window, the API returns an error, and the error message itself can also tell you the actual window limit.

Summary: what to do first when the context length isn't enough

When you hit a "context length exceeded" error or the model starts forgetting things, check in this order before switching to a larger window:

  1. Use the usage field to confirm how many tokens you are actually sending, and see whether tool definitions or message history take up most of it.
  2. Clean up or summarize the conversation history, and start a new session.
  3. Switch material that can be retrieved to on-demand retrieval instead of stuffing in the whole thing.
  4. Only when you truly need all the material, move to a long-window model, and use the script above to test recall and time to first token.
  5. Enable prompt caching for fixed prefixes to control the cost of repeated input.

Before switching models, check the current advertised context and prices on the model monitoring page, then run the script above with your own material.

Related articles

Keep reading