Nodes/ComfyUI-ZML-Image/ZML_LLM 模型加载器V2
ComfyUI Node

ZML_LLM 模型加载器V2

Keep your API key out of the workflow

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_LLM 模型加载器V2
    • 模型配置
    preset_name未选择
    config_folder
    model_override

    The first version of this loader stores your API key inside the workflow. That's fine until the day you share a PNG or a workflow JSON and realize your sk-... key just went with it - embedded in the metadata, readable by anyone. ZML_LLM_ModelLoaderV2 exists to fix exactly that, and it's the version you should use if you ever plan to share anything.

    The idea is simple: your key (and URL, and model) live in a local JSON file on your disk, and the workflow only ever stores a path to that file and a preset name. Wire it up:

    • config_folder - a folder path where a file named zml_model_key.json lives. Only the path is stored in the workflow. The author is explicit in the code comments: the path is local, it doesn't contain the key, so sharing is safe.
    • preset_name - which entry inside that JSON to use. The file has a presets array, and each preset carries name, url, key, model.
    • model_override (optional) - if you fill this in, it overrides the preset's model ID. Handy when one config folder serves several models and you don't want a file per model.

    Output is the same 模型配置 (LLM_MODEL_CONFIG) type as the V1 loader, so it drops straight into ZML_LLM_Chat. The node reads the JSON, finds the preset, returns the config dict, and never writes the key back to anything ComfyUI serializes.

    Where this genuinely shines is group settings: put zml_model_key.json in a shared folder, and a whole team (or your work + home machines) points at one key file with different preset names. It also makes switching providers a one-line edit instead of a graph edit.

    The tradeoff, and it's the reason I reach for V1 sometimes: a bare config_folder of "" with preset "未选择" returns a config with an error string baked into model_id, and it's easy to misremember the JSON structure and get Error: Preset 'xxx' not found coming back through the Chat node. There's also a small UI helper: the pack exposes a /zml/llm/load_config API route that reads presets from a folder, so the frontend can list them for you - but if you're on a fresh install, check the exact shape of the file first:

    {
      "presets": [
        { "name": "deepseek", "url": "https://api.deepseek.com", "key": "sk-...", "model": "deepseek-chat" }
      ]
    }
    

    Note the model field name - not model_id. Get that wrong and the preset silently falls back to the override or an error.

    Install is pack-standard (Manager search "ComfyUI-ZML-Image", or git clone https://github.com/zml-w/ComfyUI-ZML-Image into custom_nodes and restart). It lives under ZML 图像 → LLM. The one non-obvious dependency is openai, which the pack's requirements.txt installs and which the whole LLM set needs at runtime.

    Bottom line: for personal use, V1's convenience is fine. For anything you'll export, save as PNG, or share with a friend, use V2 - it's the difference between leaking a credential in your metadata and not. That's a lesson the ecosystem keeps relearning the hard way.

    Categoryimage/ZML_图像/LLM

    Inputs (3)

    NameTypeDefaultDescription
    preset_nameSTRING未选择
    config_folderSTRING
    model_overrideoptSTRING如果填写,将覆盖预设里的模型ID

    Outputs (1)

    NameTypeDescription
    模型配置LLM_MODEL_CONFIG