ComfyUI Node

glm prompt

Have an LLM write your Flux prompt, inside the graph

By Mcmillian·Created 2 years ago·Updated 2 years ago· 0
glm prompt
    • clip-L
    • clip-T5
    prompt
    modelglm-4-flash
    max_tokens1024
    system

    Type "a rainy Tokyo street at dusk, photorealistic" into GlmPromptNode (display name "glm prompt") and it sends that to Zhipu's GLM chat API, then hands you back two finished prompt strings split exactly the way Flux wants them: one for CLIP-L, one for T5-XXL. LLM-assisted prompting as a node in your graph, no browser tab required. Zhipu is the same Tsinghua spin-off behind CogVideoX and GLM, and this one needs no local model and no VRAM - the model runs on Zhipu's servers, so all you need is internet and a key.

    Why you'd reach for it

    Prompt-writing nodes went from "emerging practice" to standard equipment - the community converged on having an LLM translate a plain desire into a well-structured prompt rather than hand-tweaking a wall of text. This node does that translation inside ComfyUI, and it knows the Flux trick that trips people up: Flux doesn't take one prompt, it takes a CLIP-L sentence and a separate T5-XXL description. GlmPromptNode returns both, pre-split.

    How it works

    It calls ZhipuAI.chat.completions.create with your prompt and a built-in system persona (in Chinese, from the author) telling the model it's a Flux prompt builder for photorealistic images that must reply with JSON containing three fields: theme, clip-L (style description), and clip-T5 (detailed content). The node strips the markdown fences, json.loads the reply, and outputs the two strings.

    The inputs

    • prompt (required, multiline) - what you actually want, natural language is fine.
    • model (enum, default glm-4-flash) - eight GLM options; glm-4-flash is the free tier.
    • max_tokens (INT, 128–4096, default 1024) - cap on the reply length.
    • system (optional, multiline) - replaces the built-in persona. Handy if you want a different style, but the node still expects clip-L and clip-T5 keys in the JSON.

    Outputs

    • clip-L (STRING) - wire into the clip_l input of a Flux CLIPTextEncodeFlux node.
    • clip-T5 (STRING) - wire into that node's t5xxl input (it takes its dual clip from DualCLIPLoader).

    The gotchas, in order

    1. Free model, not no key. glm-4-flash costs nothing to run, but you still register at open.bigmodel.cn and paste your API key into config.json in the plugin folder. The shipped config.json has an empty CHATGLM_API_KEY, so it errors ("please set CHATGLM_API_KEY in Config.json") until you do. This is step one for everyone.
    2. It's a live API call. No internet, no output - and each run ships your prompt off to Zhipu. If you're privacy-sensitive about prompts, this isn't the tool.
    3. JSON parsing is the fragile bit. The whole node rests on the model returning valid JSON. json_repair sits in the pack's requirements, which suggests the author planned for the model occasionally mangling the reply - but the shipped code does strict json.loads, so a malformed response raises. Retry, or tighten the system prompt if you keep hitting it.
    4. It's Flux-flavored. The outputs are literally named after Flux's encoders. On SD1.5/SDXL you'd only use clip-L, and honestly a tag-oriented LLM does that job better.

    Install

    ComfyUI Manager (search "SimpleToolsNodes"), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Mcmillian/ComfyUI-SimpleToolsNodes.git
    

    Then run install.bat on Windows (it targets portable and Aki installs, else system pip) - on Linux/Mac just pip install -r requirements.txt into your ComfyUI env - and restart. The only real dependency is the zhipuai SDK; no models to download. Then open config.json in the plugin directory and drop in your key.

    CategorySimpleNode

    Inputs (4)

    NameTypeDefaultDescription
    promptSTRING
    modelCOMBOglm-4-flash8 options: glm-4-flash, glm-4, glm-4-flashx, glm-4-plus, glm-4v-plus, glm-4-0520, +2
    max_tokensINT1024128–4096
    systemoptSTRING

    Outputs (2)

    NameTypeDescription
    clip-LSTRING
    clip-T5STRING