Models and training

Context window

A context window is the maximum amount of text, measured in tokens, that a language model can take in and produce in a single request, including instructions, documents, conversation history and its own reply.

A language model has no memory between requests. Everything it knows about your task has to fit into one input: the instructions, any documents, the conversation so far and room for the answer. The context window is the size limit on that input, counted in tokens. It shapes what an AI build can do in one step, and it is one of the main reasons builds need retrieval, summarising or memory design rather than simply handing the model everything.

How it works

Each request to a model is assembled from parts: a system prompt, perhaps some retrieved passages, the recent conversation, the user's latest message. The total, plus the tokens the model will write back, must stay within the window. If it does not, the request fails or older material has to be dropped.

Context windows have grown considerably, and some models now accept very long inputs such as whole contracts or code bases. A larger window does not mean the model uses all of it equally well. Models can overlook details buried in the middle of a long input, and a long input is slower and more expensive to process every time.

So builds usually manage context deliberately. A contract review tool might split documents into passages (chunking), retrieve only the clauses relevant to a question, and keep a running summary of the conversation instead of the full transcript. Longer-running assistants use agent memory to store facts outside the window and bring back only what is needed.

What it means for cost

The context window affects cost in two directions. In running costs, every token placed in the window is billed on every request, so a design that sends a full manual with each question costs far more per answer than one that retrieves a few passages. Prompt caching can soften this when the same long prefix is reused.

In build costs, working within the window is real engineering. Deciding what to include, testing whether the model still finds the right detail, and handling inputs that are too long all take time. A builder who says the model's window is big enough to skip retrieval should be asked how answer quality, speed and per-request cost were tested at realistic document sizes.

Common questions

Is a bigger context window always better?

Not necessarily. It allows more material per request, but costs and response times rise with input length, and accuracy on details can drop in very long inputs. Many production builds deliberately send less than the maximum.

Does a large context window replace RAG?

For a small, stable set of documents it can. For large or frequently changing collections, retrieval-augmented generation is usually cheaper and more accurate, because it sends only the passages that matter and can cite where answers came from.

What happens when a conversation exceeds the window?

The application has to decide what to drop or compress, for example older messages or a summary in place of the full history. If nothing manages this, the request fails, which is a common gap in quickly built chatbots.

Related terms

Pricing a build that involves Context window? Send the brief and get a fixed price set next to the market range.Get a quote