Nodes/Lan-gpt-image-2/Lan-gpt-image-2
ComfyUI Node

Lan-gpt-image-2

The gpt-image node that doesn't care whose API you're calling

By Lan-0v0·Created 2 months ago·Updated 2 months ago· 1
Lan-gpt-image-2
  • image
  • mask
  • images
  • info
prompt
api_key
base_urlhttps://api.openai.com/v1
modelgpt-image-1
qualityauto
sizeauto
n1
backgroundopaque
moderationauto
auto_fallback_moderationtrue
output_formatpng
output_compression85
seed0
negative_prompt
timeout120
max_retries3
retry_delay2.0
extra_headers
save_to_diskfalse
output_dirlan_gpt_image_output

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/v1 for 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.

CategoryLan/gpt-image

Inputs (22)

NameTypeDefaultDescription
promptSTRINGText prompt describing the image to generate or the edit to apply.
api_keySTRINGAPI key. Leave blank to use the OPENAI_API_KEY environment variable.
base_urlSTRINGhttps://api.openai.com/v1API base URL. Use https://api.openai.com/v1 for official OpenAI, or a custom URL like http://localhost:8317/v1 for proxies.
modeloptSTRINGgpt-image-1Model name. Default: gpt-image-1. Change if your proxy/provider uses a different name.
qualityoptCOMBOautoImage quality. Affects cost and generation time.
sizeoptCOMBOautoOutput image dimensions.
noptINT11–10Number of images to generate per request.
backgroundoptCOMBOopaqueWhether the generated image has a transparent background.
moderationoptCOMBOautoContent 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_moderationoptBOOLEANtrueIf the API rejects the selected moderation level (e.g. 'none'), automatically retry with 'low' mode instead of failing.
output_formatoptCOMBOpngFormat of the returned image data from the API.
output_compressionoptINT850–100Compression level (0-100) for jpeg/webp output. Ignored for png.
seedoptINT00–18446744073709550000Random seed. May or may not be honoured by the API.
negative_promptoptSTRINGNegative prompt — describes what to avoid. (Sent only if the API supports it.)
imageoptIMAGEReference image for editing/inpainting. Connect with 'mask' to edit a specific area.
maskoptMASKInpainting mask. White (value > 0.5) = keep, black = edit area. Must be used with 'image'.
timeoutoptINT12010–600HTTP request timeout in seconds.
max_retriesoptINT30–10Maximum number of retry attempts on transient failures.
retry_delayoptFLOAT2.00–60Base delay in seconds between retries (exponential backoff applied).
extra_headersoptSTRINGAdditional HTTP headers as JSON, e.g. {"X-Custom-Header": "value"}. Useful for proxy auth.
save_to_diskoptBOOLEANfalseIf True, save generated images to output_dir.
output_diroptSTRINGlan_gpt_image_outputDirectory name for saved images. Created under ComfyUI output/ if relative.

Outputs (2)

NameTypeDescription
imagesIMAGE
infoSTRING