To change the context length in Ollama, move the context length slider in the Ollama app’s settings, or start the server with the OLLAMA_CONTEXT_LENGTH environment variable, for example OLLAMA_CONTEXT_LENGTH=64000 ollama serve.
As of December 4, 2026, Ollama’s documentation lists these options:
- App: the context length slider under settings.
- Server default:
OLLAMA_CONTEXT_LENGTHwhen runningollama serve. - Inside ollama run:
/set parameter num_ctx 8192. - API: pass
"options": {"num_ctx": 8192}in the request. - Modelfile:
PARAMETER num_ctx 8192, then build it withollama create.
Without a setting, Ollama picks a default based on VRAM: 4k context under 24 GiB, 32k for 24 to 48 GiB, and 256k at 48 GiB or more. Cloud models use their maximum context length. Ollama recommends at least 64,000 tokens for agents, web search and coding tools, warns that larger contexts need more memory, and suggests checking the CONTEXT column in ollama ps.
Related: What is the Ollama context window?, How to update Ollama? and Ollama 0.40.17 power-user guide
Source: Ollama docs, Context length; Ollama docs, FAQ (How can I specify the context window size?); Ollama docs, Modelfile reference
Image: Ollama logo by ParthSareen on behalf of Ollama, MIT License, via Wikimedia Commons. Placed on a white background and resized. Ollama is a trademark of its owner. FreeAnswers is not affiliated with or endorsed by Ollama.