Web Asset House Guides
Local AI

Keep an Ollama Model Loaded (or Unload It Now): keep_alive, Preloading and ollama stop

By Web Asset House Studio ·

Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.

How we wrote this: A plain-English summary of the official Ollama FAQ, checked October 29, 2026.

The first request to a model is slow because Ollama has to load it into memory. After that, Ollama keeps it loaded for a while. These settings control that trade-off between speed and free RAM or VRAM.

The default: 5 minutes

The Ollama FAQ says models stay in memory for 5 minutes after the last request, then unload. Run ollama ps to see what's loaded and the UNTIL column showing when each model will unload.

Unload a model right now

ollama stop llama3.2

That's handy before a game, a video call or loading a bigger model.

Preload a model

Send an empty request and the model loads without producing any text:

curl http://localhost:11434/api/generate -d '{"model": "mistral"}'

It works with /api/chat too. From the CLI: ollama run llama3.2 "".

The keep_alive parameter

On /api/generate and /api/chat, keep_alive sets how long the model stays loaded after that request:

Value Effect
"10m", "24h" A duration string
3600 A number of seconds
-1 (or any negative number) Keep it loaded indefinitely
0 Unload immediately after the response

Keep a model loaded:

curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": -1}'

Free the memory:

curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": 0}'

Change the default for every model

Set OLLAMA_KEEP_ALIVE (same value types) on the server and restart it. A keep_alive value in an API request overrides the server setting. How you set server variables depends on your system: launchctl on a Mac, systemctl edit ollama.service on Linux, Environment Variables in Windows Settings. See Ollama on Mac, Linux and Windows.

Which to choose

Related: running several models at once, is Ollama using my GPU?, CLI cheat sheet.

Sources

← All Local AI guides · All guides