Capacity planning
Choosing a model for long documents or conversation history.
AI & ML · Const
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.
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.
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.
Choosing a model for long documents or conversation history.
Keeping prompts within the selected model's token limit.
Deciding whether to reduce, retrieve, or summarize context.
tokensprompt engineeringgpt-4.1gpt-5.5