API_caption☀
Turn any image into a prompt, through the vision API of your choice
- image
- text
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:
- Siliconflow →
api.siliconflow.cn(the default) - T8zhenzhen →
api.bltcy.ai - OpenRouter →
openrouter.ai - Other → whatever
api_urlyou 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
seedfield 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_tokensof 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| api_type | COMBO | Siliconflow | 4 options: Siliconflow, T8zhenzhen, OpenRouter, Other |
| api_url | STRING | <url> | — |
| API_Key | STRING | <your_key> | — |
| model_name | STRING | Qwen/Qwen3-VL-32B-Instruct | — |
| image | IMAGE | — | |
| prompt | STRING | You 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_language | COMBO | Chinese | 2 options: Chinese, English |
| thinking_mode | BOOLEAN | false | — |
| temperature | FLOAT | 0.500–2 | — |
| max_tokens | INT | 258125–4096 | — |
| noise_seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |