feat: add Model Downloader Endpoint #12170
Open
+44
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This "model downloader" feature is wanted in some issues and PRs including #8436, #12098 and #10224. It also will let Dify self-hosters install ComfyUI server for the Dify plugin more easily as they no longer need to install comfy-asset-downloader.
A issue named Download and install queue shows a user wants a further feature in which users can queue the download tasks but I did not implement that feature.
How to use
Firstly, you need to set
Comfy.ModelDownloadEnabledon your settings to True. If you are running ComfyUI on localhost, you can set the value withcurl -X POST localhost:8188/settings/Comfy.ModelDownloadEnabled -d "true". Without this, ComfyUI returns 403 Forbidden status code and does not download models.Secondly, you make a query with the URL of the model, which directory to save it in and the filename. For example, the command
curl -X POST localhost:8188/download_model -d '{"url":"https://civitai.com/api/download/models/1714002?type=Model&format=SafeTensor&size=pruned&fp=fp16", "save_dir":"checkpoints"}'will download https://civitai.com/models/1162518/plant-milk-model-suite in checkpoint/ directory.It works not only for CivitAI but for HuggingFace as
curl -X POST localhost:8188/download_model -d '{"url":"https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors", "save_dir":"vae"}'works.You also can download members-only models by putting your API token on the query like
curl -X POST localhost:8188/download_model -d '{"url":"https://civitai.com/api/download/models/2636109?type=Model&format=SafeTensor&size=pruned&fp=fp16", "save_dir":"checkpoints", "token":"..."}'.Finally, you can use the downloaded model on the workflow.