Nodes/ComfyUI_GLM4Node/💬GLM4_CHAT
ComfyUI Node

💬GLM4_CHAT

An LLM inside your ComfyUI graph, keyed to Zhipu's GLM-4

By JcandZero·Created 3 years ago·Updated 2 years ago· 31
💬GLM4_CHAT
    • Text
    prompt你好,你是谁呀
    model_name
    api_keyYour_ZHIPU_API_KEY

    ComfyUI is a graph of strings - prompt in, prompt out - and every now and then you wish you had a general-purpose brain sitting in the middle of it. Somewhere to write you a better prompt, translate that workflow you found on civitai, or hand you a negative prompt that's more than "bad hands, extra fingers". That's exactly the slot GLM4_CHAT fills: a node that sends your text to Zhipu's GLM-4 API and returns the model's answer as a string you can wire anywhere.

    It's the workhorse of the three-node JcandZero/ComfyUI_GLM4Node pack. The vision sibling handles images; this one is pure text, and it's the node most people actually use.

    How it works

    No checkpoint, no VRAM, nothing local - this is a network call. The node creates a ZhipuAI client from your API key and makes a single chat.completions.create request against the glm-4 model. One thing the source will surprise you with: before your prompt, it injects a hardcoded four-line demo exchange - "你好 / 我是人工智能助手 / 你叫什么名字 / 我叫chatGLM" - so the model is pre-loaded with "you are a chat assistant" context. You can't change that; there's no system-prompt field, and the preamble is baked into the code.

    The inputs that matter

    Only three, all required:

    • prompt (multiline STRING) - your instruction. Defaults to "你好,你是谁呀". Multiline, so paste whole blocks of instructions without fighting a single-line box.
    • model_name - a locked dropdown with one choice, glm-4. That's it, no glm-4-flash or newer tiers, no way to pick from the UI.
    • api_key - your Zhipu key. Defaults to whatever sits in the pack's config.json, a placeholder out of the box.

    Output: Text (STRING) - the model's reply. Wire it into a positive or negative prompt node, use it as a prompt expander, or feed it straight toward the text encoder.

    Where it fits in a workflow

    The obvious move is to route the output into your prompt input and let GLM write or rewrite the text for you. One reality check from prompt-engineering land: GLM writes natural sentences, not booru tags. If you're targeting an SDXL model, ask it explicitly for comma-separated tag-style output - otherwise you'll get prose that the tag-trained models only half-heartedly obey.

    Gotchas

    • It's an API call. You need internet, a working key, and a Zhipu account with credits. If it errors, the usual suspect is the key - the README is blunt that the key in the author's demo video is dead ("The API I included in the video cannot be used"). Get your own.
    • Key hygiene matters. ComfyUI stores node input values in the workflow JSON and in exported PNG metadata. Paste a workflow with your key into a public issue and you've handed it out. The pack also has a config.json fallback in its folder - check both places before sharing.
    • No memory between runs. Every queue is a fresh call with that canned preamble. The model won't remember what you asked last run.

    If you'd rather not pay per token or send your prompts to a third party, GLM-4 also runs locally - there are local GLM wrapper nodes that run glm-4v on a consumer GPU. This node is for "I want it wired into the graph in five minutes," not "I want a private local assistant."

    Install

    You install the whole pack - all three nodes ship in one repo:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JcandZero/ComfyUI_GLM4Node
    cd ComfyUI_GLM4Node
    pip install -r requirements.txt   # just installs `zhipuai`
    

    Or via ComfyUI Manager: search "GLM4Node", install, restart. The node lands in the BlinkNodes_PROMPT menu category. No model downloads, no VRAM - just the API key and internet.

    CategoryBlinkNodes_PROMPT

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRING你好,你是谁呀
    model_nameCOMBO1 options: glm-4
    api_keySTRINGYour_ZHIPU_API_KEY

    Outputs (1)

    NameTypeDescription
    TextSTRING