Nodes/ComfyUI-My-Nodes/从配置文件获取数据
ComfyUI Node

从配置文件获取数据

Type your API key once, use it everywhere

By Tagbliton·Created 2 years ago·Updated about a year ago· 11
从配置文件获取数据
    • value
    key[ERROR] Load config

    Every AI node in this pack asks for an api_key, and pasting the same long key into a dozen nodes is exactly the kind of repetition ComfyUI was built to eliminate. This node is the pack's answer: it reads a key-value from the pack's config.json file and outputs it as a STRING, which you then wire into every node's api_key (or OSS_ACCESS_KEY, or whatever) input. Change the key once in the file, and every node in every workflow updates. That's the pattern the README recommends as "方式二" (method two) for entering your API key - you should probably be using it.

    The mechanics are plain: on load, the node parses ./custom_nodes/ComfyUI-My-Nodes/config.json and builds its key dropdown from whatever keys exist in the file. Pick a key, and the value output returns the corresponding string. The default config.json ships with api_key, base_url, OSS_ACCESS_KEY, OSS_SECRET_KEY, and bucket - but the README explicitly says you can add your own keys. It's a general-purpose settings store, not just an API-key reader.

    The one input, key, is a dropdown that populates from the file at load time. If the file is missing or malformed, the dropdown shows [ERROR] Load config and the node outputs Configuration error detected - that's the diagnostic, and it's trying to tell you something specific.

    Setup, from the README:

    1. Open ComfyUI/custom_nodes/ComfyUI-My-Nodes/config.json in a text editor.
    2. Replace YourApiKey inside the quotes with your real DashScope key (and fill in OSS keys if you use the OSS node).
    3. Save, keep the JSON valid - English punctuation only, and don't lose the commas between entries.
    4. Restart ComfyUI, or refresh node definitions and toggle the node's output (the README's shortcut is r).

    Gotchas. The [ERROR] Load config dropdown is almost always a JSON problem: a Chinese full-width comma/colon (,:) instead of ASCII, a missing comma, or a trailing comma after the last entry. The README calls this out explicitly. One more subtlety: the dropdown only refreshes when the node loads, so editing the file while ComfyUI is running won't update the key list until you refresh. And a heads-up for the security-minded - this is a plaintext file on disk with your API key in it. It's how the pack works, but keep the file out of any repo you push and treat it like a credential, which is exactly what it is.

    Category我的节点

    Inputs (1)

    NameTypeDefaultDescription
    keyCOMBO[ERROR] Load config1 options: [ERROR] Load config

    Outputs (1)

    NameTypeDescription
    valueSTRING