Nodes/m10i/Load Safetensors from URL
ComfyUI Node

Load Safetensors from URL

Download a model straight from a URL and get the filename out

By 0nyx-networks·Created 7 months ago·Updated 4 months ago· 0
Load Safetensors from URL
    • file_name
    safetensors_url
    model_type
    raise_error_on_failurefalse

    Model files are big, and downloading them is always the fiddly manual step: find a HuggingFace link, download it, move it into the right models/ folder, restart, hope the loader sees it. Load Safetensors from URL removes most of that. Give it a URL and a type, and it downloads the file, validates that it's really a safetensors, drops it into the correct models folder, and hands you back the filename - which you then feed to any normal loader. The workflow goes from "download this LoRA, then load it" to "just load it."

    How it works

    Four steps, each of which the node actually checks:

    1. Download - streams the URL over httpx (8KB chunks, 10-second timeout) into a temp file. Only http:// and https:// URLs are accepted.
    2. Validate - reads the safetensors header structure: the first 8 bytes are a little-endian header size, and the header itself must parse as a JSON dictionary. If that fails, the file is rejected. This is a real format check, not a filename sniff, which is nicer than most "download this file" nodes bother with.
    3. Name and save - it computes a SHA3-512 hash of the content and saves the file as download_<hash>_<size>.safetensors in the first folder of the chosen model_type (pick loras and it lands in ComfyUI/models/loras/, for example).
    4. Cache - the URL→path mapping is stored in a diskcache (10GB cap) under a .safetensors_url_cache folder, so re-running the workflow skips the download entirely. Re-downloads only happen if the cached file was deleted.

    The output is just the file name, not a path - which is exactly what ComfyUI loaders expect.

    Inputs and outputs

    • safetensors_url - the direct download URL.
    • model_type - dropdown: checkpoints, clip_vision, controlnet, loras, text_encoders… and one broken option (see below).
    • raise_error_on_failure (optional) - default false.

    Output: file_name (STRING).

    The gotcha in the dropdown

    Read the list carefully and you'll spot diffustion_models - yes, misspelled. It's in the pack's source, not a typo you made, and it matters: ComfyUI's actual folder key is diffusion_models, so selecting that option raises a KeyError, which with raise_error_on_failure off silently returns an empty filename. You cannot download a diffusion-style model with this node as shipped. Use loras, checkpoints, controlnet, clip_vision, or text_encoders - those all resolve to real folders.

    Also note the output is only the filename: for LoRAs, wire it straight into the pack's LoadLoRAFromFile and the loop closes. For a checkpoint you'll still pick it in a dropdown loader afterward (it appears there once saved). And don't expect the filename to be pretty - it's a hash, by design, so identical content always gets the same name and you never double-download.

    Install

    ComfyUI Manager → search "comfy-nekonote-extensions", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/0nyx-networks/comfy-nekonote-extensions
    

    Restart ComfyUI; it's under NEKONOTE → Load. The pack (MINETA "m10i" Hiroki, MIT, v0.4.7) downloads models into your machine - it needs no model files of its own, but it does need httpx and diskcache, so let Manager install requirements if the node errors on first use. It targets the newer comfy_api.latest backend API; keep ComfyUI current.

    CategoryNEKONOTE/Load

    Inputs (3)

    NameTypeDefaultDescription
    safetensors_urlSTRING
    model_typeCOMBO6 options: checkpoints, clip_vision, controlnet, diffustion_models, loras, text_encoders
    raise_error_on_failureoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    file_nameSTRING