Lan-gpt-image-2
The gpt-image node that doesn't care whose API you're calling
- image
- mask
- images
- info
The name is the headline, so get it straight: this node doesn't run a model, and "gpt-image-2" is mostly optimism. Lan-gpt-image-2 is a single-node pack whose whole trick is a configurable base_url. It takes your prompt (and optionally a reference image), POSTs it to any OpenAI-compatible image endpoint, and drops the returned image back into your graph as a normal IMAGE tensor. Official OpenAI, a local proxy, an Azure deployment, some reseller - the node doesn't care, because you tell it where to go.
Why does that matter? GPT Image has no open weights, so the only way it enters a ComfyUI workflow is through an API node. The README says this pack exists because its predecessor, ComfyUI-oshtz-nodes, hardcoded https://api.openai.com/v1 and couldn't talk to anything else. This one exposes the endpoint as an input, which unlocks the actually interesting use case: a local proxy like cli-proxy-api at http://localhost:8317/v1, letting you keep your key and routing on your own machine. The "gpt-image-2" in the title is a real closed model people started talking about in spring 2026, but the default model here is gpt-image-1 - and since model is a free-text field, you just type whatever your proxy exposes.
How it works
Under the hood it's a plain HTTP client (the requests library - no GPU, no model files). It resolves the key from the api_key input or the OPENAI_API_KEY env var, and the base URL from its input or OPENAI_BASE_URL/OPENAI_API_BASE (env only wins if you leave the input at default). With no image connected it POSTs JSON to /images/generations; connect an image and it switches to /images/edits as a multipart form, adding a mask file if you've wired one. Transient failures - 429s, 5xx, connection drops, timeouts - retry with exponential backoff (retry_delay × attempt), and there's a genuinely thoughtful moderation fallback: set moderation to none, and if the API rejects it with a message containing "moderation", it auto-retries with low unless you flip auto_fallback_moderation off.
The inputs that matter
- prompt (required) - the generation or edit instruction, multiline.
- api_key (required, but leave blank to use
OPENAI_API_KEY). - base_url (required) - the whole point.
http://localhost:8317/v1for the local proxy. - model - free-text, default
gpt-image-1; type any proxy-exposed name. - quality / size / n - your cost controls (
auto/low/medium/high, a fixed size list, 1–10 images per request). - image + mask - wire a reference image to edit, add a mask for inpainting. Mind the polarity: white (value > 0.5) = keep, black = edit area, the opposite of some ComfyUI conventions.
- seed - the tooltip is honest: "may or may not be honoured by the API." Don't build a workflow that needs exact reproduction.
Outputs are images (an IMAGE tensor you pipe into Save Image, VHS, or an upscaler) and info (a STRING with endpoint, model, mode, elapsed time, and tensor shape - a handy debug port).
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/Lan-0v0/ComfyUI-Lan-gpt-image-2
pip install -r requirements.txt
Then restart ComfyUI and search "Lan-gpt-image-2" (category Lan/gpt-image). ComfyUI Manager finds it too, since the pack publishes a registry entry. The requirements are just requests, Pillow, numpy, torch - every ComfyUI already has all four, so this is effectively clone-and-restart. No weights to download, because there are no weights.
Where people get burned
It's an API node, which means the usual rules from this category apply: a key that a malicious pack could lift, data leaving your machine, per-call cost. This one is small enough to skim - roughly 800 lines, one node - and reading it before pasting in a key is exactly the habit this category deserves. Also: on first run it auto-writes a config.json in the plugin folder, gitignored, with an api_key slot - fine, but the env-var route keeps your key out of files entirely. A mask without an image is a hard error, and output_compression only does anything for jpeg/webp.
Last honest caveat: this pack is brand new with essentially zero community footprint - no threads, no installs to speak of. It works today and its dependencies are boring and stable, but don't expect a support community if your proxy breaks. For the "closed model, my own endpoint" gap, it's currently the most flexible option I've seen.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Text prompt describing the image to generate or the edit to apply. | |
| api_key | STRING | API key. Leave blank to use the OPENAI_API_KEY environment variable. | |
| base_url | STRING | https://api.openai.com/v1 | API base URL. Use https://api.openai.com/v1 for official OpenAI, or a custom URL like http://localhost:8317/v1 for proxies. |
| modelopt | STRING | gpt-image-1 | Model name. Default: gpt-image-1. Change if your proxy/provider uses a different name. |
| qualityopt | COMBO | auto | Image quality. Affects cost and generation time. |
| sizeopt | COMBO | auto | Output image dimensions. |
| nopt | INT | 11–10 | Number of images to generate per request. |
| backgroundopt | COMBO | opaque | Whether the generated image has a transparent background. |
| moderationopt | COMBO | auto | Content moderation strictness. 'auto' = standard filtering, 'low' = less restrictive, 'none' = disable moderation (only works if the API/proxy supports it; enable auto_fallback_moderation to retry with 'low' if rejected). |
| auto_fallback_moderationopt | BOOLEAN | true | If the API rejects the selected moderation level (e.g. 'none'), automatically retry with 'low' mode instead of failing. |
| output_formatopt | COMBO | png | Format of the returned image data from the API. |
| output_compressionopt | INT | 850–100 | Compression level (0-100) for jpeg/webp output. Ignored for png. |
| seedopt | INT | 00–18446744073709550000 | Random seed. May or may not be honoured by the API. |
| negative_promptopt | STRING | Negative prompt — describes what to avoid. (Sent only if the API supports it.) | |
| imageopt | IMAGE | Reference image for editing/inpainting. Connect with 'mask' to edit a specific area. | |
| maskopt | MASK | Inpainting mask. White (value > 0.5) = keep, black = edit area. Must be used with 'image'. | |
| timeoutopt | INT | 12010–600 | HTTP request timeout in seconds. |
| max_retriesopt | INT | 30–10 | Maximum number of retry attempts on transient failures. |
| retry_delayopt | FLOAT | 2.00–60 | Base delay in seconds between retries (exponential backoff applied). |
| extra_headersopt | STRING | Additional HTTP headers as JSON, e.g. {"X-Custom-Header": "value"}. Useful for proxy auth. | |
| save_to_diskopt | BOOLEAN | false | If True, save generated images to output_dir. |
| output_diropt | STRING | lan_gpt_image_output | Directory name for saved images. Created under ComfyUI output/ if relative. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| info | STRING | — |