ComfyUI/comfy_api
Jedrzej Kosinski 2f7b77f341 feat: add model download API gated behind --enable-download-api
Add a new server-side download API that allows frontends and desktop apps
to download models directly into ComfyUI's models directory, eliminating
the need for DOM scraping of the frontend UI.

New files:
- app/download_manager.py: Async download manager with streaming downloads,
  pause/resume/cancel, manual redirect following with per-hop host validation,
  sidecar metadata for safe resume, and concurrency limiting.

API endpoints (all under /download/, also mirrored at /api/download/):
- POST /download/model - Start a download (url, directory, filename)
- GET /download/status - List all downloads (filterable by client_id)
- GET /download/status/{id} - Get single download status
- POST /download/pause/{id} - Pause (cancels transfer, keeps temp)
- POST /download/resume/{id} - Resume (new request with Range header)
- POST /download/cancel/{id} - Cancel and clean up temp files

Security:
- Gated behind --enable-download-api CLI flag (403 if disabled)
- HTTPS-only with exact host allowlist (huggingface.co, civitai.com + CDNs)
- Manual redirect following with per-hop host validation (no SSRF)
- Path traversal protection via realpath + commonpath
- Extension allowlist (.safetensors, .sft)
- Filename sanitization (no separators, .., control chars)
- Destination re-checked before final rename
- Progress events scoped to initiating client_id

Closes Comfy-Org/ComfyUI-Desktop-2.0-Beta#293

Amp-Thread-ID: https://ampcode.com/threads/T-019d2344-139e-77a5-9f24-1cbb3b26a8ec
Co-authored-by: Amp <amp@ampcode.com>
2026-03-24 23:47:59 -07:00
..
input CURVE node (#12757) 2026-03-24 17:47:28 -04:00
input_impl ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
internal comfy_api: remove usage of "Type","List" and "Dict" types (#11238) 2025-12-15 16:01:10 -08:00
latest CURVE node (#12757) 2026-03-24 17:47:28 -04:00
torch_helpers Make torch.compile LoRA/key-compatible (#8213) 2025-05-21 04:56:56 -04:00
util ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
v0_0_1 ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
v0_0_2 Add MatchType, DynamicCombo, and Autogrow support to V3 Schema (#10832) 2025-12-03 00:17:13 -05:00
feature_flags.py feat: add model download API gated behind --enable-download-api 2026-03-24 23:47:59 -07:00
generate_api_stubs.py ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
util.py ComfyAPI Core v0.0.2 (#8962) 2025-07-29 22:17:22 -04:00
version_list.py comfy_api: remove usage of "Type","List" and "Dict" types (#11238) 2025-12-15 16:01:10 -08:00