ZML_LLM 模型加载器V2
Keep your API key out of the workflow
- 模型配置
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 namedzml_model_key.jsonlives. 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 apresetsarray, and each preset carriesname,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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| preset_name | STRING | 未选择 | — |
| config_folder | STRING | — | |
| model_overrideopt | STRING | 如果填写,将覆盖预设里的模型ID |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 模型配置 | LLM_MODEL_CONFIG | — |