ComfyUI_OpenAI_GPTImage2
Official OpenAI GPT-Image-2 API nodes for ComfyUI: Text-to-Image & Image Editing with multi-image support
ComfyUI OpenAI GPT-Image-2 Nodes
ComfyUI custom nodes for OpenAI GPT Image generation and image editing.
Nodes
- GPT-Image-2 Text-to-Image: calls the Images API with
gpt-image-2. - GPT-Image-2 Image Edit: calls the Images API edit endpoint with
gpt-image-2. - GPT-Image-2 Image Edit (Responses API, file cache): uploads input images as files, reuses cached
file_idvalues in the current ComfyUI process, and calls the Responses API with theimage_generationtool.
All nodes keep the same outputs:
image: generated image tensorurl:(base64)for base64 image resultsresponse: request summary or error text
Model Types
gpt-image-2 and gpt-5.x models are not the same kind of model.
| Field | Typical value | Used by | Purpose |
| --- | --- | --- | --- |
| image_model | gpt-image-2 | Images API or image_generation tool | Renders generated or edited images |
| responses_model | gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano | Responses API | Understands the request and calls tools |
For the T2I and Images Edit nodes, the node directly uses gpt-image-2.
For the Responses Edit node, choose:
responses_model: the main Responses API model. Default:gpt-5.5.image_model: the GPT Image model used by theimage_generationtool. Default:gpt-image-2.image_model = auto: omit the tool model and let the API choose.custom_responses_model/custom_image_model: use these only when the dropdown is set tocustom.
Install
Install the requirements into the same Python environment used by ComfyUI:
E:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install -r requirements.txt
Then restart ComfyUI.
API Key
Each node keeps api_key as a node input. Paste your OpenAI API key into the node before running the workflow.
Proxy And TLS
The optional proxy field accepts values such as:
http://127.0.0.1:7890socks5://127.0.0.1:1080
The client currently uses verify=False in httpx.Client to improve compatibility with local proxy setups that intercept TLS. Keep this in mind when using untrusted networks or proxies.
Size Limits
Custom output size is validated before the API request:
- Width and height must be positive.
- Width and height must be multiples of
16. - Maximum edge length is
3840px. - Total pixels must be between
655360and8294400. - Aspect ratio must be no more than
3:1.
Examples:
1024x1024: valid1536x1024: valid2048x2048: valid3840x2160: valid256x256: invalid because total pixels are too low3840x3840: invalid because total pixels are too high
Common Errors
- API Key Required: fill the
api_keyfield. - Prompt Required: enter a non-empty prompt.
- Invalid Size: adjust width and height to satisfy the size limits above.
- Too Many Images: edit nodes support up to
16input images. - Connection Failed: set or check the proxy if your network cannot reach the OpenAI API directly.
- No Image in Response: the API returned successfully but did not include image data; check the model fields and prompt.
Notes
- The Responses Edit node cache is in memory only. Restarting ComfyUI clears cached
file_idvalues. - Masking with GPT Image is prompt-guided. The mask helps guide edits, but exact mask boundaries are not guaranteed.
seedinputs are kept for workflow compatibility and metadata, but the current API calls do not pass a seed parameter.