[GH-ISSUE #13142] feat: add API endpoint to cancel/abort ongoing model downloads #8694

Open
opened 2026-04-12 21:28:03 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @akhileshthite on GitHub (Nov 19, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/13142

Use Case: 

PeerSky Browser is integrating Ollama as the local LLM provider for P2P web applications. Users can download models through our UI, but currently there's no way to cancel downloads once started. This creates poor UX when users accidentally start downloading large models (70GB+) or change their mind mid-download.

Image

Current Behavior: 

The /api/pull endpoint starts a model download but provides no mechanism to stop it. Even when clients abort the HTTP connection, the download continues server-side until completion. The only workaround is to kill the entire Ollama process.

Proposed Solution: 

Add a new API endpoint to cancel ongoing downloads:

# Cancel current download
DELETE /api/pull

# Or cancel specific model download
DELETE /api/pull/{model_name}

Alternative Approaches:

  1. Add a cancel field to the existing /api/pull endpoint
  2. Include a download ID in pull responses that can be used for cancellation
  3. Add a generic /api/downloads/{id}/cancel endpoint

This would enable browser-based UIs like PeerSky to provide proper download management with cancel buttons, improving user experience for applications that embed Ollama.

Related: https://github.com/p2plabsxyz/peersky-browser/pull/96

Originally created by @akhileshthite on GitHub (Nov 19, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/13142 ### Use Case:  [PeerSky Browser](https://github.com/p2plabsxyz/peersky-browser) is integrating Ollama as the local LLM provider for P2P web applications. Users can download models through our UI, but currently there's no way to cancel downloads once started. This creates poor UX when users accidentally start downloading large models (70GB+) or change their mind mid-download. <img width="800" height="625" alt="Image" src="https://github.com/user-attachments/assets/a2e2ba32-ceb9-4374-9e04-a8e280d9aee3" /> ### Current Behavior:  The `/api/pull` endpoint starts a model download but provides no mechanism to stop it. Even when clients abort the HTTP connection, the download continues server-side until completion. The only workaround is to kill the entire Ollama process. ### Proposed Solution:  Add a new API endpoint to cancel ongoing downloads: ```bash # Cancel current download DELETE /api/pull # Or cancel specific model download DELETE /api/pull/{model_name} ``` #### Alternative Approaches: 1. Add a `cancel` field to the existing `/api/pull` endpoint 2. Include a download ID in pull responses that can be used for cancellation 3. Add a generic `/api/downloads/{id}/cancel` endpoint This would enable browser-based UIs like PeerSky to provide proper download management with cancel buttons, improving user experience for applications that embed Ollama. Related: https://github.com/p2plabsxyz/peersky-browser/pull/96
GiteaMirror added the feature request label 2026-04-12 21:28:03 -05:00
Author
Owner

@pdevine commented on GitHub (Nov 19, 2025):

@akhileshthite can you not just hang up on the stream?

<!-- gh-comment-id:3550377022 --> @pdevine commented on GitHub (Nov 19, 2025): @akhileshthite can you not just hang up on the stream?
Author
Owner

@akhileshthite commented on GitHub (Nov 19, 2025):

@akhileshthite can you not just hang up on the stream?

Hanging up on the stream unfortunately doesn’t stop the download, the server continues pulling the model even after the HTTP connection is closed.

That’s why a cancellation endpoint is needed. Without it, the only way to stop a download is to kill the entire Ollama process, which isn’t practical for UI-based integrations

<!-- gh-comment-id:3550391288 --> @akhileshthite commented on GitHub (Nov 19, 2025): > [@akhileshthite](https://github.com/akhileshthite) can you not just hang up on the stream? Hanging up on the stream unfortunately doesn’t stop the download, the server continues pulling the model even after the HTTP connection is closed. That’s why a cancellation endpoint is needed. Without it, the only way to stop a download is to kill the entire Ollama process, which isn’t practical for UI-based integrations
Author
Owner

@pdevine commented on GitHub (Nov 19, 2025):

It should stop the download, as that's how the ollama CLI and App work. You don't need to kill the ollama server. You can check the Ollama CLI's source code in cmd/cmd.go specifically in PullHandler(). If the CLI gets a sigint it will stop downloading the model (although it does store the partial download in ~/.ollama/models/blobs/*.-patial* until the server it restarted.

<!-- gh-comment-id:3550501868 --> @pdevine commented on GitHub (Nov 19, 2025): It should stop the download, as that's how the ollama CLI and App work. You don't need to kill the ollama server. You can check the Ollama CLI's source code in `cmd/cmd.go` specifically in `PullHandler()`. If the CLI gets a sigint it will stop downloading the model (although it does store the partial download in `~/.ollama/models/blobs/*.-patial*` until the server it restarted.
Author
Owner

@viva2b commented on GitHub (Dec 28, 2025):

Hi @pdevine,

I'd like to work on this issue. Before implementing, I want to confirm the approach:

Option A: Fix context propagation

  • Ensure PullModel properly respects context cancellation
  • No new API needed, just fix the existing behavior

Option B: Add explicit cancel endpoint

  • DELETE /api/pull/{model} to cancel specific download
  • Requires tracking active downloads

Which approach would you prefer? Or is there another solution you have in mind?

<!-- gh-comment-id:3694467017 --> @viva2b commented on GitHub (Dec 28, 2025): Hi @pdevine, I'd like to work on this issue. Before implementing, I want to confirm the approach: **Option A: Fix context propagation** - Ensure `PullModel` properly respects context cancellation - No new API needed, just fix the existing behavior **Option B: Add explicit cancel endpoint** - `DELETE /api/pull/{model}` to cancel specific download - Requires tracking active downloads Which approach would you prefer? Or is there another solution you have in mind?
Author
Owner

@rick-github commented on GitHub (Jan 14, 2026):

Option A.

<!-- gh-comment-id:3748900354 --> @rick-github commented on GitHub (Jan 14, 2026): Option A.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#8694