Nodes/ComfyUI-DataSet/DataSet_OpenAIChatImage
ComfyUI Node

DataSet_OpenAIChatImage

The Pack's Flagship Captioner

By daxcay·Created 2 years ago·Updated about a year ago· 58
DataSet_OpenAIChatImage
  • image
  • STRING
â—„image_detailhighâ–º
â—„promptâ–º
â—„modelgpt-4oâ–º
â—„api_urlhttps://api.openai.com/v1â–º
â—„token_length1024â–º

If this pack has a flagship, it's this node. DataSet_OpenAIChatImage feeds an image to GPT-4o's vision API and returns a natural-language caption as a STRING. In a pack built for "data research, preparation, and manipulation for model trainers," this is the captioning engine - the node the whole load-save pipeline is designed around.

And captioning quality is the right place to spend money. Training lore is unambiguous: caption quality beats dataset size, the caption style has to match your target model (natural language for LLM-encoder models like Flux, tags for the Danbooru lineage), and generic tag dumps produce forgettable results. GPT-4o writes genuinely good natural-language captions. If you're training on Flux or Z-Image and you want captions that carry real descriptive detail, this is the quality bar the pack offers.

Inputs

  • image - an IMAGE tensor. DataSet_LoadImage is the natural source because it hands you the filename too, which you'll need for saving.
  • image_detail - low or high. high (default) is more accurate and costs more per call; low is fine for simple subjects and halves the vision cost. Tune it per dataset, not per run.
  • prompt - the caption instruction. "Write a detailed natural-language caption" beats the empty default every time.
  • model - defaults to gpt-4o; the dropdown also carries the older GPT-4 family, which mostly don't do vision, so leave it on 4o.
  • api_url - the OpenAI-compatible base URL, default https://api.openai.com/v1. Same override trick as the text node - point it at a compatible provider if you want.
  • token_length - response cap, default 1024.

Output: a single STRING caption.

How it works

The node takes the first frame of your image tensor, converts it to a base64 PNG in memory, and sends it to the OpenAI chat API as an image_url data URI with your chosen detail level, alongside your prompt. Every run is a live, paid API call. The natural pipeline is: DataSet_LoadImage → this node → caption → DataSet_TextFilesSave, with the filename string riding along the whole way so your caption files land with the right names.

The key situation: OPENAI_API_KEY

No key widget. Set OPENAI_API_KEY in your environment before launching ComfyUI and restart:

export OPENAI_API_KEY=sk-...

Missing key = a STRING output that says "OpenAI API key is required." Errors never crash the queue in this pack - they come back as text - so always glance at what the node actually returned before assuming it worked.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-DataSet.git
cd ComfyUI-DataSet && pip install -r requirements.txt

Restart. No local model, no VRAM - the only dependency that matters is your wallet and the openai package from requirements.txt.

Two honest notes. First, watch your bill: a few hundred images at high detail adds up. Second, sanity-check one caption before you run the whole folder - at this price you don't want to discover your prompt wording was off after 500 API calls. If the captions read like a person wrote them, let it run.

Category🔶DATASET🔶

Inputs (6)

NameTypeDefaultDescription
imageIMAGE—
image_detailCOMBOhigh2 options: low, high
promptSTRING—
modelCOMBOgpt-4o8 options: gpt-4o, gpt-4, gpt-4-32k, gpt-3.5-turbo, gpt-4-0125-preview, gpt-4-turbo-preview, +2
api_urlSTRINGhttps://api.openai.com/v1—
token_lengthINT1024—

Outputs (1)

NameTypeDescription
STRINGSTRING—