Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI & ML · Const

Context Window

A context window is the token-based memory limit for a model during a generation request. It determines how much input and conversational material the model can consider, and its size varies by model.

How it works

A context window is the token-based working memory available during one model generation request. It covers the input supplied to the model and limits how much conversation, instructions, retrieved data, and generated output can fit together; exact capacity depends on the selected model.

Key points

  • The context window is a token-based limit on the information a model can consider for a generation request.
  • The counted context is measured in tokens and can represent different input modalities, including text and images.
  • Available capacity varies substantially between models, ranging from roughly 100,000 tokens to about one million for newer models.

Common mistakes

  • A request can exceed the model's available working context, so keep the combined prompt and included material within the selected model's limit.
  • Context-window capacity is model-specific; check the selected model's documentation instead of assuming one universal limit.

Example: Inspect a model's context capacity

from openai import OpenAI

client = OpenAI()
response = client.responses.create(
    model="gpt-4.1",
    input="Explain context windows in one sentence."
)
print(response.output_text)

This runnable example sends a request to a model whose documentation specifies a context-window capacity.

When to use it

Capacity planning

Choosing a model for long documents or conversation history.

Prompt sizing

Keeping prompts within the selected model's token limit.

Context management

Deciding whether to reduce, retrieve, or summarize context.

  • tokens
  • prompt engineering
  • gpt-4.1
  • gpt-5.5

Source: Prompt engineering | OpenAI API. Checked 2026-10-15.