Nodes/Duanyll Nodepack/OpenAI Image Generation
ComfyUI Node

OpenAI Image Generation

Cloud Image Generation Inside Your Local Graph (Yes, It Needs a Key)

By Duanyll·Created about a year ago·Updated 4 months ago· 2
OpenAI Image Generation
  • client
  • extra_body
  • image
  • response
prompt
modelgpt-image-2
sizeauto
custom_size
qualityauto
backgroundauto
output_formatauto
output_compression100
moderationauto
styleauto
n1
user

Not everything has to run on your GPU. OpenAIImageGeneration calls OpenAI's /images/generations endpoint from inside a ComfyUI graph - the model runs in the cloud (default gpt-image-2, with the older gpt-image-1 variants and DALL-E 2/3 in the list), and the image comes back as a normal IMAGE tensor in your workflow.

This is the node you add when you want a cloud model as a step in a local pipeline: generate a draft with the API, then continue with your local upscalers, LoRAs, or edits downstream. It's also handy for quick comparisons against local models without leaving the graph.

The name is a hint and a warning: it does call an API, and it does need a key. This is not local inference.

How it works

You need the pack's CreateOpenAIClient node feeding the client input - that's where the API key lives (or it falls back to the OPENAI_API_KEY environment variable). The generation node builds the payload for POST /images/generations with whatever options you set, runs it, downloads the returned image, and decodes it into an IMAGE. The raw API response also comes out of the second output (response, an any-type slot) if you want to inspect it.

Relevant knobs: prompt (the one that matters), model, size (auto picks per model; presets from 1024² up to 3840×2160, or custom with your own dimensions in custom_size), quality, background (transparent only really makes sense with png output), output_format, output_compression, moderation, style, n (batch count), and extra_body for anything not covered.

Installing it

Part of Duanyll Nodepack:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

or via ComfyUI Manager, then restart. The pack uses plain requests, so there's no OpenAI SDK to install - you just need outbound HTTPS.

Where people get burned

  • Missing key = instant error. CreateOpenAIClient raises if you leave api_key blank and OPENAI_API_KEY isn't set. There's no silent mode.
  • It costs money. Every queue run is a paid API call. Easy to forget when the node sits in an automated graph that runs hundreds of times.
  • Model-dependent limits. Size presets aren't universal - some sizes exist only for newer models, and old DALL-E models ignore most of these knobs. When a combination is rejected, the API's error text comes back through and usually names the offending field.
  • Transparency needs PNG. Request background=transparent with output_format=jpeg and you'll get... an opaque JPEG, because JPEG has no alpha. The output_compression setting also only applies to jpeg/webp.
  • Keep the key out of shared workflows. The client node holds your API key in plain text in the graph. Strip it before sharing a workflow JSON.

If you want the same "call an image API" behavior without OpenAI's particular models, the pack's base_url on the client lets you point at compatible endpoints - that's how the author wires it to alternative providers. But out of the box, this is an OpenAI-API node, billed accordingly.

Categoryduanyll/models/openai

Inputs (14)

NameTypeDefaultDescription
clientOPENAI_CLIENT
promptSTRING
modeloptCOMBOgpt-image-26 options: gpt-image-2, gpt-image-1.5, gpt-image-1, gpt-image-1-mini, dall-e-3, dall-e-2
sizeoptCOMBOauto11 options: auto, custom, 1024x1024, 1536x1024, 1024x1536, 2048x2048, +5
custom_sizeoptSTRING
qualityoptCOMBOauto6 options: auto, high, medium, low, hd, standard
backgroundoptCOMBOauto3 options: auto, transparent, opaque
output_formatoptCOMBOauto4 options: auto, png, jpeg, webp
output_compressionoptINT1000–100
moderationoptCOMBOauto2 options: auto, low
styleoptCOMBOauto3 options: auto, vivid, natural
noptINT11–10
useroptSTRING
extra_bodyopt*

Outputs (2)

NameTypeDescription
imageIMAGE
response*