Nodes/ComfyUI_ChatGLM_API/ZhipuaiApi_img
ComfyUI Node

ZhipuaiApi_img

Sentence captions, not tag soup — GLM-4V image captioning over the cloud

By smthemex·Created 2 years ago·Updated 2 years ago· 25
ZhipuaiApi_img
  • image
  • text
promptDescribe this image
max_tokens1024
temperature0.80
output_language

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 - English or Original_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 PyJWT and opencv-python, both of which the code imports - if the nodes won't register, pip install PyJWT opencv-python sorts 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.

CategoryChatGlm_Api

Inputs (5)

NameTypeDefaultDescription
promptSTRINGDescribe this image
imageIMAGE
max_tokensINT1024128–8192
temperatureFLOAT0.800.01–0.99
output_languageCOMBO2 options: English, Original_language

Outputs (1)

NameTypeDescription
textSTRING