[PR #5407] [CLOSED] [RFC] Add ollama save/load api and cli to save and load model #22307

Closed
opened 2026-04-19 16:14:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/5407
Author: @coolljt0725
Created: 7/1/2024
Status: Closed

Base: mainHead: save_load_3


📝 Commits (1)

  • a56b01a Add ollama save/load api and cli to save and load model

📊 Changes

9 files changed (+565 additions, -21 deletions)

View changed files

📝 README.md (+12 -0)
📝 api/client.go (+93 -0)
📝 api/types.go (+10 -0)
📝 cmd/cmd.go (+75 -0)
server/load.go (+210 -0)
📝 server/manifest.go (+7 -0)
📝 server/modelpath.go (+5 -21)
📝 server/routes.go (+60 -0)
server/save.go (+93 -0)

📄 Description

Add ollama save ollama load cli and GET /api/save, POST /api/load api to save a model from server and load a model from ollama save.

$ ./ollama save --help
Save a model

Usage:
  ollama save MODEL -o LOCALFILE.tar [flags]

Flags:
  -h, --help            help for save
  -o, --output string   Name of the local file

Environment Variables:
      OLLAMA_HOST                IP Address for the ollama server (default 127.0.0.1:11434)
$ ./ollama load --help
load a model from file or from STDIN

Usage:
  ollama load -i LOCALFILE.tar [flags]

Flags:
  -h, --help           help for load
  -i, --input string   Name of the local tar file to load

Environment Variables:
      OLLAMA_HOST                IP Address for the ollama server (default 127.0.0.1:11434)

Usage

$ ./ollama save -o llama3.tar llama3

This will create a llama3.tar on the current directory

$ ./ollama load -i llama3.tar
loaded: 'llama3:latest'

The layout of the tarball is

manifests/registry.ollama.ai/library/llama3/latest
blobs/sha256-6a0746a1ec1aef3e7ec53868f220ff6e389f6f8ef87a01d77c96807de94ca2aa
blobs/sha256-4fa551d4f938f68b8c1e6afa9d28befb70e3f33f75d0753248d530364aeea40f
blobs/sha256-8ab4849b038cf0abc5b1c9b8ee1443dca6b93a045c2272180d985126eb40bf6f
blobs/sha256-577073ffcc6ce95b9981eacc77d1039568639e5638e83044994560d9ef82ce1b
blobs/sha256-3f8eb4da87fa7a3c9da615036b0dc418d31fef2a30b115ff33562588b32c691d
index.json

TODO: add docs and test cases


🔄 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/5407 **Author:** [@coolljt0725](https://github.com/coolljt0725) **Created:** 7/1/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `save_load_3` --- ### 📝 Commits (1) - [`a56b01a`](https://github.com/ollama/ollama/commit/a56b01aea7d292196151a03275ddbb23a77eabc5) Add ollama save/load api and cli to save and load model ### 📊 Changes **9 files changed** (+565 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+12 -0) 📝 `api/client.go` (+93 -0) 📝 `api/types.go` (+10 -0) 📝 `cmd/cmd.go` (+75 -0) ➕ `server/load.go` (+210 -0) 📝 `server/manifest.go` (+7 -0) 📝 `server/modelpath.go` (+5 -21) 📝 `server/routes.go` (+60 -0) ➕ `server/save.go` (+93 -0) </details> ### 📄 Description Add `ollama save ` `ollama load` cli and `GET /api/save`, `POST /api/load` api to save a model from server and load a model from ollama save. ``` $ ./ollama save --help Save a model Usage: ollama save MODEL -o LOCALFILE.tar [flags] Flags: -h, --help help for save -o, --output string Name of the local file Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) ``` ``` $ ./ollama load --help load a model from file or from STDIN Usage: ollama load -i LOCALFILE.tar [flags] Flags: -h, --help help for load -i, --input string Name of the local tar file to load Environment Variables: OLLAMA_HOST IP Address for the ollama server (default 127.0.0.1:11434) ``` Usage ```` $ ./ollama save -o llama3.tar llama3 ```` This will create a `llama3.tar` on the current directory ``` $ ./ollama load -i llama3.tar loaded: 'llama3:latest' ``` The layout of the tarball is ``` manifests/registry.ollama.ai/library/llama3/latest blobs/sha256-6a0746a1ec1aef3e7ec53868f220ff6e389f6f8ef87a01d77c96807de94ca2aa blobs/sha256-4fa551d4f938f68b8c1e6afa9d28befb70e3f33f75d0753248d530364aeea40f blobs/sha256-8ab4849b038cf0abc5b1c9b8ee1443dca6b93a045c2272180d985126eb40bf6f blobs/sha256-577073ffcc6ce95b9981eacc77d1039568639e5638e83044994560d9ef82ce1b blobs/sha256-3f8eb4da87fa7a3c9da615036b0dc418d31fef2a30b115ff33562588b32c691d index.json ``` TODO: add docs and test cases --- <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-19 16:14:38 -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#22307