DataSet_ClaudeAIChatImage
Caption a Stack of Images With Claude's Eyes
- image
- STRING
This is the vision sibling of DataSet_ClaudeAIChat: same Claude API, same env-var key, but with an IMAGE input instead of text-only. You feed it an image, give it a caption instruction, and it returns a STRING describing what it sees. In a dataset-preparation context that's the whole game - auto-captioning images before a LoRA run.
It matters because caption quality is the single biggest lever in training after dataset selection. The community consensus, repeated in every serious training write-up, is that generic taggers produce forgettable captions and hand-captioning is the gold standard. This node is a middle path: Claude's descriptions are natural-language and noticeably better than a naive tag dump, which is exactly what the LLM-encoder era of models (Flux, Z-Image, Qwen-Image) wants.
How it works
The node takes your IMAGE tensor, converts the first frame to a base64-encoded PNG in memory, and sends it to Anthropic's messages API alongside your user_prompt. No local model, no VRAM hit, no PIL wheels beyond what ComfyUI already has - the work all happens on Anthropic's servers. Each run is a paid API call, so "caption 10,000 images" is a bill, not a freebie.
Inputs and output
- image - an IMAGE tensor. Comes naturally out of
DataSet_LoadImage(also in this pack) or any stock LoadImage node. - model -
claude-3-5-sonnet-latest,claude-3-5-haiku-latest, orclaude-3-opus-latest. Sonnet's the default and the right call for captioning; haiku if you're doing volume. - user_prompt - the caption instruction, e.g. "Write a detailed natural-language caption describing the subject, pose, and style."
- max_tokens - response cap, default 1024.
Output is a single STRING. There's no image_detail control like the OpenAI variant has - Claude decides its own resolution handling.
The key gotcha: ANTHROPIC_API_KEY
No key widget here either. Set the env var before launching ComfyUI:
export ANTHROPIC_API_KEY=sk-ant-...
Miss it and the node returns a STRING starting with Error: rather than failing loudly, which reads as a silent failure if you're not watching. That error-string convention is the pack-wide gotcha to remember.
Wiring it into a training pipeline
The natural loop: DataSet_LoadImage → DataSet_ClaudeAIChatImage → collect the caption STRING → DataSet_TextFilesSave writes image_name.txt next to your images. Keep the filename wiring straight by pulling the name output off DataSet_LoadImage - that's the exact reason that node exposes name and path strings alongside the image.
Install is the pack standard - clone, pip install -r requirements.txt, restart. The anthropic client comes from requirements. Then set the key, run one image, and sanity-check the caption before you spend a day's worth of API calls on the whole folder.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model | COMBO | claude-3-5-sonnet-latest | 3 options: claude-3-5-sonnet-latest, claude-3-5-haiku-latest, claude-3-opus-latest |
| user_prompt | STRING | — | |
| max_tokens | INT | 1024 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |