ComfyUI Node

API_caption☀

Turn any image into a prompt, through the vision API of your choice

By Hasasasa·Created about a year ago·Updated 2 months ago· 7
API_caption☀
  • image
  • text
api_typeSiliconflow
api_url<url>
API_Key<your_key>
model_nameQwen/Qwen3-VL-32B-Instruct
promptYou are a professional AI image generation prompt engineer. Please describe in detail the main body, foreground, mid-ground, background, composition, visual guidance, color tone, and light and shadow atmosphere of this image, and create an image prompt with depth, atmosphere, and artistic appeal. Requirements: Chinese prompt, no description of image watermark, no irrelevant words or symbols, no summary, limited to 800 words.
output_languageChinese
thinking_modefalse
temperature0.50
max_tokens258
noise_seed0

There's a whole genre of node that reads an image and writes a text description of it - "image2prompt" - and it's one of the most useful things a vision API can do for you. API_caption is the DashuaiTools version: it sends one image to a multimodal chat API and returns a generated description, ready to be used as a prompt for txt2img or as a caption in a dataset.

If you're training a LoRA, captioning is the highest-impact step after choosing your images, and the current advice for LLM-encoder models like Z-Image and Qwen-Image is natural-language captions - exactly what this node produces. If you're just trying to reverse-engineer the prompt behind an image you like, it does that too, in one click.

How it works

The node encodes your IMAGE tensor as a lossless PNG, base64-wraps it as a data:image/png;base64,... URI, and POSTs it to an OpenAI-style /v1/chat/completions endpoint with the image in a content array alongside your system prompt. It's provider-aware:

  • Siliconflowapi.siliconflow.cn (the default)
  • T8zhenzhenapi.bltcy.ai
  • OpenRouteropenrouter.ai
  • Other → whatever api_url you type

The plumbing is decent for a hobby pack: it retries on 429/5xx, strips <think>...</think> blocks from reasoning models, and if the API rejects the thinking flag it retries once without it. The default model is Qwen/Qwen3-VL-32B-Instruct, a strong open vision model.

Inputs that matter

  • API_Key - required; get one from whichever provider you pick.
  • model_name - defaults to Qwen3-VL-32B; on OpenRouter you'd put something like a Gemini or GPT-4o class model instead.
  • image - the IMAGE tensor to describe.
  • prompt - the system instruction. The default asks for a detailed Chinese description ("limited to 800 words"), covering subject, foreground, composition, lighting. You'll almost certainly want to rewrite this for English output or a specific style.
  • output_language - Chinese or English; it appends a "return in X" instruction to your prompt.
  • temperature, max_tokens, thinking_mode, noise_seed - the usual knobs. Seed is passed through as a seed field where the backend supports it.

Output: text, a single STRING.

Gotchas

  • It's a paid API call. Every Queue run spends tokens. The default max_tokens of 258 is small and deliberately so.
  • Keep the key secret. The API_Key lives in the workflow; if you share workflows publicly, strip it or use ComfyUI's key-management options.
  • Big images get sent at full size as PNG. That's a fat payload; if your provider has size limits you may hit them.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Hasasasa/ComfyUI_DashuaiTools
cd ComfyUI_DashuaiTools
pip install -r requirements.txt

then restart ComfyUI, or install through ComfyUI Manager. The node needs requests, which the pack declares.

The sibling node Batch_API_caption does the same thing for a whole folder at once - if you find yourself captioning more than a few images, go straight to that one.

CategoryDaNodes/API

Inputs (11)

NameTypeDefaultDescription
api_typeCOMBOSiliconflow4 options: Siliconflow, T8zhenzhen, OpenRouter, Other
api_urlSTRING<url>
API_KeySTRING<your_key>
model_nameSTRINGQwen/Qwen3-VL-32B-Instruct
imageIMAGE
promptSTRINGYou are a professional AI image generation prompt engineer. Please describe in detail the main body, foreground, mid-ground, background, composition, visual guidance, color tone, and light and shadow atmosphere of this image, and create an image prompt with depth, atmosphere, and artistic appeal. Requirements: Chinese prompt, no description of image watermark, no irrelevant words or symbols, no summary, limited to 800 words.
output_languageCOMBOChinese2 options: Chinese, English
thinking_modeBOOLEANfalse
temperatureFLOAT0.500–2
max_tokensINT258125–4096
noise_seedINT00–18446744073709550000

Outputs (1)

NameTypeDescription
textSTRING