{"head":{"title":"What Is a Context Window in an LLM? | OceanLab","description":"The context window is the most tokens a model can take in and produce in one request. What fills it, how it affects cost and quality, and how to use it.","canonical":"https://oceanlab.in/glossary/context-window"},"crumbs":[{"name":"Home","path":"/"},{"name":"Glossary","path":"/glossary"},{"name":"context window","path":"/glossary/context-window"}],"slug":"context-window","term":"Context window","aka":["context length"],"category":"LLM costs","short":"The most tokens a model can take in and produce in one request.","body":[["The context window covers everything the model sees in one call: the system prompt, tool definitions, any documents or chat history you send, and the reply it writes. It is measured in ",{"href":"/glossary/token","text":"tokens"},". If a request does not fit, it fails or has to be cut down."],["A bigger window allows longer inputs, such as whole contracts or long conversations. It does not make the model remember anything between calls; each request starts fresh with whatever you send."]],"why":["Every input token is billed, so filling a large window on every call is expensive, and some providers charge a higher rate above a length threshold. Very long inputs can also make answers worse, because the important part is buried. Sending the right few passages, as in ",{"href":"/glossary/rag","text":"RAG"},", is often cheaper and better than sending everything."],"example":["A contract-review tool first sent every contract in full. Switching to sending only the clauses that match the question cut input tokens on most calls, and reviewers found the answers easier to check because each one pointed to a specific clause."],"inBuild":null,"mistakes":[["Treating the window as memory. The app has to send the history again on every call."],["Sending everything because it fits. Fitting is not the same as being useful or cheap."],["Leaving no room for the reply. Output tokens share the same window."]],"related":[{"href":"/glossary/token","label":"Token (LLM)","detail":"The unit an AI language model reads and writes, and the unit most LLM APIs bill by."},{"href":"/glossary/prompt-caching","label":"Prompt caching","detail":"Reusing the processed start of a prompt across calls, so repeated input is billed at a lower rate."},{"href":"/glossary/rag","label":"RAG (retrieval-augmented generation)","detail":"A pattern that finds relevant passages from your own data and gives them to a language model along with the question, so it answers from your content."},{"href":"/glossary/llm","label":"LLM (large language model)","detail":"An AI model trained on very large amounts of text that predicts the next piece of text, which lets it read, write and reason in language."}],"tools":[{"href":"/tools/token-counter","label":"Token counter","detail":"Free tool"},{"href":"/tools/llm-api-cost-calculator","label":"LLM API cost calculator","detail":"Free tool"},{"href":"/tools/rag-cost-calculator","label":"RAG cost calculator","detail":"Free tool"}],"links":[{"href":"/pricing/categories/llm-api","label":"LLM API pricing","detail":"Model prices side by side, with sources."},{"href":"/ai","label":"AI by industry","detail":"AI use cases, costs and risks per industry."}],"sources":[],"legal":false,"updatedAt":"2026-10-25"}