Mac tip: keep an Ollama model warm with keep_alive

Mac mini lifestyle productivity scene from Apple Newsroom

After a chat ends, Ollama still holds the model in memory for a while. The FAQ default is five minutes. Then it unloads. The next reply has to reload weights again.

On Apple silicon that reload costs time. keep_alive and OLLAMA_KEEP_ALIVE change how long a model stays loaded. You can also preload so the first token is ready sooner. This is separate from the ollama stop unload tip, which clears memory right away.

Check what is loaded with ollama ps

Open Terminal and run:

ollama ps

The list shows NAME, SIZE, PROCESSOR, and UNTIL. UNTIL is the unload timer. On Apple silicon the PROCESSOR column may read 100% GPU, CPU, or a split. That is what the CLI prints. It does not invent a VRAM number for you.

To drop a model now:

ollama stop llama3.2

Replace the name with whatever ollama ps listed. If Ollama is not installed yet, follow the Apple silicon Ollama install guide first.

Mac mini agentic AI scene from Apple Newsroom

Preload and keep_alive on the API

Both /api/generate and /api/chat accept keep_alive. Docs allow a duration string such as "10m" or "24h", a number of seconds, -1 to keep the model loaded indefinitely, or 0 to unload after the response.

Preload with an empty generate call and keep the model warm:

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

An empty chat body works the same way when you pass messages as an empty list. From the CLI you can also run:

ollama run llama3.2 ""

That loads the model without a real prompt. Later requests hit memory instead of a cold start.

To unload through the API, send keep_alive as 0 with an empty prompt or empty messages. Same idea as ollama stop, just over HTTP.

MacBook Pro running Capture One from Apple Newsroom

Set OLLAMA_KEEP_ALIVE on macOS

The environment variable OLLAMA_KEEP_ALIVE uses the same value types as the API field. On a Mac the FAQ path is launchctl, then a restart of the Ollama app:

launchctl setenv OLLAMA_KEEP_ALIVE "24h"

Quit Ollama from the menu bar and open it again so the process picks up the env. A value of 0 means unload after each response. A negative value keeps models loaded until you stop them.

Per-request keep_alive on generate or chat still overrides the default for that call. Use the env when you want the same policy for every local session.

Local weights versus cloud tags

Downloaded models live under ~/.ollama on macOS. Prompts to those local weights stay on the Mac. A cloud tag sends the prompt off-machine.

If the rule is local-only, apply the turn off Ollama cloud tip before you lean on long keep_alive values. Warm memory only helps when the weights you care about are already on disk.

For a different local UI, the LM Studio lms CLI tip covers another Mac workflow. Ollama’s own OpenAI-compatible endpoint is covered in the Ollama OpenAI API tip if you wire clients that way.

Photo: Apple

Source: Ollama Docs (FAQ keep_alive / OLLAMA_KEEP_ALIVE, API generate and chat, macOS environment variables); Apple Newsroom (Mac mini lifestyle productivity, Mac mini agentic AI, MacBook Pro Capture One)

Previous Article Mac fix: Touch ID isn't working on MacBook or Magic Keyboard