ChatGLM-4 Instruct Node
Turn a rough idea into a full prompt with an LLM
- STRING
You type "cyberpunk alley at night" and want back a full, detailed, model-ready prompt - the kind with lighting, camera angle, mood, and specific visual detail baked in, instead of three words. That's what ChatGLM4InstructNode does: it's a general instruction node that sends your query plus an instruction template to an LLM and returns whatever text the model generates. Prompt expansion is the obvious use, but it's really just "run an LLM call and get text back" - you decide what the instruction asks for.
Why you'd reach for it
This is exactly the shift the wider community has been making: LLM-assisted prompting used to mean pasting your idea into a separate ChatGPT tab and copying the result back. Now it's a node in the graph. As one community summary put it, the workflow that's converged on is "always read the official prompt guides first... then have an LLM translate what you want into a well structured prompt following the guide" - this node is that step, built in, so you don't break your workflow to go do it elsewhere.
Because the instruct field is a raw editable template, you're not limited to prompt expansion. Swap the instruction text and you can use this node for anything else you'd ask an LLM to do with a short piece of text - rewriting, summarizing, format conversion - as long as the output is plain text you can feed onward.
How it works
The node combines your instruct template (which contains a {query} placeholder) with your query text, substitutes your query into the template, and sends the result to a GLM model hosted on Z.ai's API. Whatever the model returns comes out as a single string.
The inputs and outputs that matter
query- your short input: the rough idea, the thing you want expanded or transformed. Multiline.instruct(default: "Generate details text, without quotation marks or the word 'prompt' on english: {query}") - the actual instruction sent to the model, with{query}as the substitution point for your input above. This is the field to actually edit if you want different behavior - change it to ask for a different style, a different output format, or a completely different task. The default is tuned specifically for prompt expansion (note it explicitly tells the model not to wrap output in quotes or say the word "prompt," which are common LLM tics that would otherwise pollute your generated prompt).model(defaultglm-4.5-flash) - 16 GLM model choices, fromglm-4-plusthroughglm-4.7and various-flash/-airvariants. Flash models are cheaper and faster; step up only if output quality on a complex instruction disappoints you.max_tokens(default 1024) - cap on response length; raise it if your instruction asks for something long and you're seeing truncated output.temperature(default 0.95) /top_p(default 0.7) - sampling controls. High temperature here is deliberate for this use case - you generally want some creative variation in an expanded prompt, unlike the translation nodes where you'd dial it down.
Output is a single STRING - wire it into a CLIP Text Encode, a PreviewTextNode to check it first, or chain it into another text node entirely.
How to install it
Via ComfyUI Manager: search "ComfyUI Custom Nodes AlekPet" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet
Restart ComfyUI. You'll need a Z.ai (Zhipu) API key configured before this does anything - the top-level README doesn't cover per-node API setup, so check the ChatGLMNode subfolder in the repo for where the key goes.
Common issues & troubleshooting
Authentication errors. Unconfigured API key - this is a paid hosted API call, not a local or free node.
Output includes quote marks, the word "prompt," or other meta-commentary you didn't want. Edit the instruct template - the default already tries to suppress exactly these tics, but different models and different queries will still occasionally slip. Be explicit in your instruction about format constraints; LLMs generally follow direct formatting instructions reliably.
Generated prompt is too similar every time, or too wild and unusable. That's temperature. Lower it for more consistent, conservative expansions; raise it (it's already fairly high at 0.95 by default) if you want more variety across runs with the same query.
Response gets cut off mid-sentence. Raise max_tokens - 1024 is generous for a single expanded prompt but can bite if your instruct template asks for something longer, like multiple prompt variations in one call.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | glm-4.5-flash | The model code to be called. Models with text 'flash' should be free! |
| max_tokens | INT | 1024 | The maximum number of tokens for model output, maximum output is 4095, default value is 1024. |
| temperature | FLOAT | 0.950–1 | Sampling temperature, controls the randomness of the output, must be a positive number within the range: [0.0, 1.0], default value is 0.95. |
| top_p | FLOAT | 0.700–1 | Another method of temperature sampling, value range is: [0.0, 1.0], default value is 0.7. |
| instruct | STRING | Generate details text, without quotation marks or the word 'prompt' on english: {query} | Enter the instruction for the neural network to execute and indicate where to insert the query text {query} |
| query | STRING | Query field |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |