Glm_4_9b_Chat
Run GLM-4 chat locally in ComfyUI — no API key, just a big GPU
- prompt
The pack is called ComfyUI_ChatGLM_API, but this node is the name's biggest lie - it calls no API and needs no key. Glm_4_9b_Chat loads Zhipu AI's open THUDM/glm-4-9b-chat model straight off HuggingFace and runs it on your own GPU via transformers. If you want a local LLM writing, translating, or expanding prompts inside your graph without sending text anywhere, this is the one. It's a 2024-era take on what's since become a whole genre of "LLM-assisted prompting" - the idea that if your image model's encoder reads natural language, having an LLM write that language is a translation between two things that already speak the same dialect.
How it works
Simple under the hood: the node takes your user_content, pushes it through AutoTokenizer.apply_chat_template(), loads AutoModelForCausalLM in bfloat16 on CUDA, and runs a greedy-ish generation with do_sample=True plus top_k. The reply is decoded with special tokens stripped, and out comes a plain string. The model is a ~9B-parameter GLM-4, so "local" here means you need serious hardware - figure ~20GB VRAM in bf16.
The inputs that matter
- repo_id - a forced input, meaning it has to be wired, not typed. It's meant to come from the pack's
Glm_Lcoal_Or_Reposelector node (or any string you feed it). This is the model's HF repo path. - user_content - your message. Multiline, so you can paste a chunk of story, a draft prompt, or a whole request.
- max_length (default 2500) - the total generation window. Your output can't exceed this; drop it to 500–1000 for snappier prompt rewrites.
- top_k (default 1) - set to 1 and sampling is effectively greedy; crank it toward 50–100 for varied, looser output.
- reply_language - an enum that quietly appends "answer me in English / 用中文回复我 / …" to your prompt, so you don't have to write the instruction yourself.
Original_languageleaves your input language alone.
Output: a single STRING named prompt. Wire it into a CLIP text encode as your conditioning, a show-text node, or a Stringify-style utility - that's the whole point of it living in ComfyUI.
Installing it
The node comes with the pack, so install the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_ChatGLM_API
Then restart ComfyUI. ComfyUI Manager works too - search "ComfyUI_ChatGLM_API". The local nodes need no config.json and no API key; that's only for the Zhipu cloud nodes in the same pack.
One trap the README itself warns about: this pack pins transformers==4.41.1 in requirements.txt, but the GLM-4 repos need a newer transformers to load at all. If you're using this node, update transformers - pip install -U transformers - and don't be surprised that the old pin disagrees with what the code actually wants.
Common issues
- First run downloads ~20GB from HuggingFace. It looks frozen; it isn't. Run it once, wait, then it loads locally.
- ImportError on startup - the pack's requirements list misses two imports the code uses (
jwtandcv2). If the nodes won't register,pip install PyJWT opencv-pythonfixes it. - OOM - hardcoded
device = "cuda"with bf16 on a 9B model. Under ~20GB VRAM, you'll want a quantized GLM-4 from a GGUF-style loader instead; this node won't do it for you. - If the reply language comes out wrong, remember the node only appends a language instruction - GLM-4 will usually follow it, but it's not a hard constraint.
It's an old, low-profile pack (all six nodes hover near zero usage), and this node is the most demanding of the lot. If you have the VRAM and want a fully offline GLM-4 chat that can hand its answer straight to your sampler's text encoder, it works - just budget the download and the RAM.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| repo_id | STRING | — | |
| max_length | INT | 2500100–10000 | — |
| top_k | INT | 11–100 | — |
| user_content | STRING | 你好! | — |
| reply_language | COMBO | 8 options: english, chinese, russian, german, french, spanish, +2 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |