ComfyUI Node

OpenAI API

GPT-4o in your ComfyUI graph for captions and prompts

By al-swaiti·Created 2 years ago·Updated 2 months ago· 185
OpenAI API
  • image
  • text
promptWhat is the meaning of life?
model
max_tokens1024
temperature0.7
top_p0.7
streamfalse

This node drops a ChatGPT-family model into your ComfyUI workflow. You give it a prompt, optionally hand it an image, and it returns text. In practice that means two things: it reads pictures (caption a render, describe a reference, build training captions), and it writes text (turn your rough idea into a polished prompt, or generate any string your graph needs downstream). It's the OpenAI sibling of the pack's Gemini, Claude, Qwen, and Ollama nodes - same shape, different provider behind it.

What it's good at, and what it costs

The draw is quality: GPT-4o is a strong vision-language model, and if you already pay for the OpenAI API this is a clean way to use it without leaving ComfyUI. The catch is right there too - unlike the Gemini node's free tier or Ollama's run-it-locally-for-nothing, OpenAI is pay-per-call. Every generation spends real money against your account. For the common job here (rewriting a prompt, captioning an image) that's fractions of a cent, but it's not zero, and a batch of 500 images captioned one-by-one adds up.

How it works

Standard chat completion. Your prompt goes in as the user message, the model responds, you get the text back. Wire an image into the optional image input and set a vision-capable model, and it'll look at the picture - that's the auto-captioner use case. There's no separate "structure output" template system on this node like the Gemini and Ollama ones have; if you want it to write a prompt, you just tell it to in your prompt text ("Write a detailed FLUX prompt for: a cat astronaut"). That's arguably cleaner anyway.

The inputs and outputs that matter

  • prompt - your instruction. This is where the work happens.
  • model - fifteen choices spanning the gpt-4o-mini, gpt-3.5-turbo, and o1 families. For captioning and prompt-writing, gpt-4o-mini is the sweet spot: cheap, fast, vision-capable, and more than smart enough. Save the reasoning o1 models for something that actually needs them.
  • max_tokens (default 1024, up to 4096) - caps the response length. A prompt rarely needs more than a few hundred tokens; leave it.
  • temperature (default 0.7) - creativity dial. Lower for consistent captions, higher for varied prompt ideas.
  • image (optional) - feed a picture for vision tasks.

The single output is text, a string. It goes into a CLIP Text Encode, a Save Text node, or any string input. Note stream exists but does nothing useful inside a batch graph - leave it off.

Installing it and the key

Through ComfyUI Manager: search ComfyUI-OllamaGemini, install, restart. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/al-swaiti/ComfyUI-OllamaGemini
pip install -r requirements.txt

then restart. Get an API key from platform.openai.com (you'll need billing set up - this is the paid one), and put it in the pack's config file as OPENAI_API_KEY.

Where people get burned

The one worth taking seriously is trust. Your OpenAI key lives in a plaintext config that any installed custom node can read, and custom nodes are arbitrary Python running with full access to your machine. This pack is open and MIT-licensed, but the ecosystem's cautionary tale is directly relevant: the 2024 ComfyUI_LLMVISION malware smuggled an infostealer inside a fake build of the openai library - precisely the dependency an OpenAI node installs. So clone from the real repo above, keep your install updated, and treat an API key as something you should be ready to rotate.

Beyond that: watch your spend if you batch (each call bills), don't reach for o1 when gpt-4o-mini will do, and if the node never appears after install, it's almost always a failed dependency in the pack - check the startup console for a red import error rather than the node menu.

CategoryAI API/OpenAI

Inputs (7)

NameTypeDefaultDescription
promptSTRINGWhat is the meaning of life?
modelCOMBO15 options: gpt-4o-mini, gpt-4o-mini-2024-07-18, gpt-3.5-turbo, gpt-3.5-turbo-0125, gpt-3.5-turbo-16k, gpt-3.5-turbo-1106, +9
max_tokensINT10241–4096
temperatureFLOAT0.70–2
top_pFLOAT0.70–1
streamBOOLEANfalse
imageoptIMAGE

Outputs (1)

NameTypeDescription
textSTRING