ZhipuaiApi_img
Sentence captions, not tag soup — GLM-4V image captioning over the cloud
- image
- text
The tagger alternative that talks like a human. ZhipuaiApi_img sends your image to Zhipu AI's cloud GLM-4V model and gets back a natural-language description - the "image is a woman in a red coat standing in rain, shallow depth of field, film grain" kind, not the "1girl, coat, rain, depth_of_field" kind. If you've got WD14-adjacent workflows where the tags just don't read well to an LLM-encoded image model, a sentence caption frequently lands better. And because it's a cloud call, there's no 26GB vision model squatting on your VRAM.
How it works
Your IMAGE tensor gets converted to a PIL image, re-encoded to a base64 PNG string, and POSTed to https://open.bigmodel.cn/api/paas/v4/chat/completions with model: glm-4v and a message that carries both your text prompt and the image as an image_url. Your API key rides along as a short-lived JWT. The reply is returned as a single cleaned-up string. The README frames it as "like WD14, but with GLM-4V doing the reverse-prompting" - that's exactly the slot it fills.
The inputs that matter
- image - any IMAGE from your graph. Caption a reference photo you loaded, or a frame you just generated.
- prompt - your instruction, multiline, default "Describe this image". Make it pointed: "Describe the lighting and camera settings" gets you a different answer than a plain caption.
- max_tokens (default 1024, range 128–8192) - how long the caption can be. 1024 is plenty for most captions.
- temperature (default 0.8) - randomness; lower it if captions get too flowery.
- output_language -
EnglishorOriginal_language(answer in the language you asked in).
Output: a single STRING named text. The classic move: caption a reference image, pipe the sentence into a CLIP text encode, and re-render in the same style - or run it through the pack's translation node to localize the caption.
Installing it (and the key)
cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_ChatGLM_API
Restart, then put a Zhipu API key (from open.bigmodel.cn) into the pack's config.json:
{
"Zpai_API_KEY": "your key"
}
The file lives at ComfyUI/custom_nodes/ComfyUI_ChatGLM_API/config.json and gets auto-created with a placeholder on first load. Pricing for GLM-4V runs ¥0.1/千tokens - a caption costs fractions of a cent, and new accounts ship with free starter tokens.
Common issues
- Images over ~5MB get rejected. The README warns the API only accepts images under 5MB, and base64 inflates your payload by ~33%. Crop or downscale before the node, not after.
- NSFW is filtered at the source - and the README warns uploading explicit content can get your Zhipu account banned. Keep captions clean.
- "API key is required" means config.json wasn't filled in.
- The pack's requirements file forgets
PyJWTandopencv-python, both of which the code imports - if the nodes won't register,pip install PyJWT opencv-pythonsorts it.
If you want the same vision-captioning capability with zero cloud calls, the pack's local Glm_4v_9b node does it on your GPU - but you'd better have a 24GB+ card. For everyone else, this is the practical pick.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Describe this image | — |
| image | IMAGE | — | |
| max_tokens | INT | 1024128–8192 | — |
| temperature | FLOAT | 0.800.01–0.99 | — |
| output_language | COMBO | 2 options: English, Original_language |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |