[PR #3094] [MERGED] Default Keep Alive environment variable #42313

Closed
opened 2026-04-24 22:05:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/3094
Author: @pdevine
Created: 3/13/2024
Status: Merged
Merged: 3/13/2024
Merged by: @pdevine

Base: mainHead: pdevine/defaultkeepalive


📝 Commits (4)

  • 7e5e973 add OLLAMA_KEEP_ALIVE env variable to set the default keep alive
  • 500d584 handle non-duration values
  • a055e60 added parsing tests for the session duration
  • d8b6b4b remove struct duration test

📊 Changes

2 files changed (+81 additions, -3 deletions)

View changed files

api/types_test.go (+50 -0)
📝 server/routes.go (+31 -3)

📄 Description

This change adds a new environment variable called OLLAMA_KEEP_ALIVE which sets how long a model will be loaded into memory. It uses the same semantics as the keep_alive parameter in the generate, chat, and embeddings API calls, namely:

  • if set to a positive value, it will default to whatever time was set
  • if set to zero it will unload immediately after generation
  • if set to a negative value it will remain in memory

You can either use a value in seconds (e.g. OLLAMA_KEEP_ALIVE=60 for 60 seconds), or as a duration string (e.g. OLLAMA_KEEP_ALIVE=10m).

This change works with both the API, and with the REPL.

Fixes #2508


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/3094 **Author:** [@pdevine](https://github.com/pdevine) **Created:** 3/13/2024 **Status:** ✅ Merged **Merged:** 3/13/2024 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `pdevine/defaultkeepalive` --- ### 📝 Commits (4) - [`7e5e973`](https://github.com/ollama/ollama/commit/7e5e973558bc8a77bcb6717354c5b2b754eef7f3) add OLLAMA_KEEP_ALIVE env variable to set the default keep alive - [`500d584`](https://github.com/ollama/ollama/commit/500d584abc7d52cb74d6bb6a07e1af537dd6d4c1) handle non-duration values - [`a055e60`](https://github.com/ollama/ollama/commit/a055e6051e4ce53de4782d513a5d35be236e5587) added parsing tests for the session duration - [`d8b6b4b`](https://github.com/ollama/ollama/commit/d8b6b4b13459f954dbd7045cdf984491a84519a4) remove struct duration test ### 📊 Changes **2 files changed** (+81 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `api/types_test.go` (+50 -0) 📝 `server/routes.go` (+31 -3) </details> ### 📄 Description This change adds a new environment variable called `OLLAMA_KEEP_ALIVE` which sets how long a model will be loaded into memory. It uses the same semantics as the `keep_alive` parameter in the `generate`, `chat`, and `embeddings` API calls, namely: * if set to a positive value, it will default to whatever time was set * if set to zero it will unload immediately after generation * if set to a negative value it will remain in memory You can either use a value in seconds (e.g. `OLLAMA_KEEP_ALIVE=60` for 60 seconds), or as a duration string (e.g. `OLLAMA_KEEP_ALIVE=10m`). This change works with both the API, and with the REPL. Fixes #2508 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-24 22:05:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#42313