Preload an Ollama model into memory and unload it immediately (keep_alive control)

domain: ollama.com · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Preload for faster first response: POST /api/generate with {"model": "llama3.2"} and an empty/omitted prompt, or POST /api/chat with "messages": []. The call returns immediately with done:true (chat returns done_reason: "load").
  2. Unload now: same empty request plus "keep_alive": 0 — response has done_reason: "unload".
  3. Per-request residency: keep_alive accepts a duration string ("10m", "24h"), seconds as a number (3600), 0 (unload right after the response), or a negative value like -1 (keep loaded indefinitely). Default is 5m.
  4. Server-wide default: start the server with OLLAMA_KEEP_ALIVE set (same value formats). The per-request keep_alive on /api/generate and /api/chat overrides it.
  5. Verify residency with GET /api/ps (shows loaded models and their expires_at).

Known gotchas

Give your agent this knowledge — and 18,200+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans