OpenAI Image Generation
Cloud Image Generation Inside Your Local Graph (Yes, It Needs a Key)
- client
- extra_body
- image
- response
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.
CreateOpenAIClientraises if you leaveapi_keyblank andOPENAI_API_KEYisn'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=transparentwithoutput_format=jpegand you'll get... an opaque JPEG, because JPEG has no alpha. Theoutput_compressionsetting 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.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| client | OPENAI_CLIENT | — | |
| prompt | STRING | — | |
| modelopt | COMBO | gpt-image-2 | 6 options: gpt-image-2, gpt-image-1.5, gpt-image-1, gpt-image-1-mini, dall-e-3, dall-e-2 |
| sizeopt | COMBO | auto | 11 options: auto, custom, 1024x1024, 1536x1024, 1024x1536, 2048x2048, +5 |
| custom_sizeopt | STRING | — | |
| qualityopt | COMBO | auto | 6 options: auto, high, medium, low, hd, standard |
| backgroundopt | COMBO | auto | 3 options: auto, transparent, opaque |
| output_formatopt | COMBO | auto | 4 options: auto, png, jpeg, webp |
| output_compressionopt | INT | 1000–100 | — |
| moderationopt | COMBO | auto | 2 options: auto, low |
| styleopt | COMBO | auto | 3 options: auto, vivid, natural |
| nopt | INT | 11–10 | — |
| useropt | STRING | — | |
| extra_bodyopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| response | * | — |