Nodes/GPT-Image (OpenAI-compatible)/GPT-Image 编辑 (图生图)
ComfyUI Node

GPT-Image 编辑 (图生图)

One image in, sized from its own dimensions, changed

By meomeo-dev·Created 5 months ago·Updated 4 months ago· 4
GPT-Image 编辑 (图生图)
  • 配置
  • 图片1
  • 图片2
  • 图片3
  • 图片4
  • 图片5
  • 图片6
  • 图片7
  • 图片8
  • 遮罩
  • 图像
◄提示词►
◄模型gpt-image-2►
◄宽0►
◄高0►
◄输入保真度default►
◄数量0►
◄质量default►
◄背景default►
◄输出格式default►
◄压缩质量100►
◄审核级别default►
◄流式false►
◄流式预览数2►
◄超时秒数900►
◄重试次数2►
◄返回格式default►

The sibling node to GPTImage's generate is built for one specific job: "change this image." GPTImageEdit takes exactly one required IMAGE input, reads its dimensions, and hands it to the same streaming /v1/chat/completions endpoint that the generate node uses. No aspect ratio dropdown, no resolution games in the prompt - because the edit's output ratio comes straight from your input image. It's the node you grab when you want to fix a face, restyle an existing render, or nudge a composition while keeping the source's shape.

How it works

The mechanism mirrors GPTImage: the input image becomes a base64 PNG data URL in the message, the request streams ("stream": true, same Cloudflare-timeout reasoning as the generate node), and the returned image - direct URL, b64_json, or markdown reference - gets downloaded and converted to an IMAGE tensor. The one real difference is the size logic in gpt_image_edit_size_for.

Set resolution to auto and the node sends no size at all - the model just edits at whatever it decides. Set it to 1K, 2K, or 4K and the node scales the long edge of your input to the target while preserving its aspect ratio:

1K -> long edge ~1280
2K -> long edge ~2048
4K -> long edge ~3840

So a 2560x2560 input at 4K requests 3840x3840; a 3000x2000 input at 4K requests 3840x2560. Same shape, higher ceiling. The README is explicit that the node never rewrites your prompt - what you type is what gets sent, which is the right call for an edit node where the user knows what they want changed.

Inputs

api_key, base_url, and model (the same five-model dropdown: gpt-image-2-vip, gpt-image-2, nano-banana, nano-banana-2, nano-banana-pro) - then prompt, resolution (default auto), timeout_seconds (default 600, 60–3600), and the required image input. Output is a single image tensor.

Same per-model resolution caps apply as on the generate node: gpt-image-2 and nano-banana are 1K-only, and requesting 2K/4K on them errors immediately rather than burning a failed request. gpt-image-2-vip, nano-banana-2, and nano-banana-pro handle up to 4K.

Install

Part of the Chat-Image-Bridge-Node pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Marigold1122/Chat-Image-Bridge-Node.git ComfyUI-ChatImageBridge
pip install -r ComfyUI-ChatImageBridge/requirements.txt

Restart, then api -> Chat Image Bridge -> GPT Image Edit (ComfyUI Manager: search "Chat-Image-Bridge-Node"). Dependency is just requests.

Troubleshooting

  • "image is required for GPT Image Edit" - the one input this node must have, checked before anything is sent. Leave it unplugged and you get this exact message.
  • "model supports resolution X, but got Y" - the 1K-only models being asked for more. Pick 1K or switch models.
  • Nothing happened / stream error - same family of issues as the generate node: provider refused, streamed text with no image, or the relay doesn't actually stream. The error preview tells you what came back.
  • If the edit comes back at a different shape than you expected, you're likely on auto resolution - the model decided. Setting an explicit resolution pins the long edge.

For pure text-to-image with no source, use GPTImage instead; this node is deliberately edit-shaped and doesn't even expose an aspect ratio, because your input image already is one.

CategoryGPT-Image

Inputs (26)

NameTypeDefaultDescription
配置IMAGE_API_CONFIG—
提示词STRING—
模型STRINGgpt-image-2—
宽INT00–3840—
高INT00–3840—
图片1IMAGE—
图片2optIMAGE—
图片3optIMAGE—
图片4optIMAGE—
图片5optIMAGE—
图片6optIMAGE—
图片7optIMAGE—
图片8optIMAGE—
遮罩optMASK—
输入保真度optCOMBOdefault参考图的保真度:high 更贴近原图细节,low 更自由。default=不发送(服务端默认)。gpt-image-2 会忽略此项(始终 high)。
数量optINT00–10一次生成几张。0 = 不发送 n 字段,由服务端定(通常 1),兼容性最好;要一次多张就填 2~10。若网关报 `n 必须是…整数` 之类的 400,保持 0。
质量optCOMBOdefault5 options: default, auto, high, medium, low
背景optCOMBOdefault4 options: default, auto, transparent, opaque
输出格式optCOMBOdefault4 options: default, png, jpeg, webp
压缩质量optINT1000–100仅对「输出格式」为 jpeg/webp 生效(png/default 会忽略)。数值=保留的画质百分比:越高画质越好、文件越大;越低压缩越强、文件越小、画质越差。默认 100=最高画质。注意它只影响文件编码,不影响生成画面(画面质量由「质量」控制)。
审核级别optCOMBOdefault3 options: default, auto, low
流式optBOOLEANfalse—
流式预览数optINT20–3—
超时秒数optINT90030–3600—
重试次数optINT20–5遇到 429/5xx/超时/连接重置时的最大重试次数。0=不重试。总请求次数 = 重试次数 + 1。也用于「从网关图床下载成品图」那一步的重试。上游高峰不稳时建议 3~5。注意:4xx(参数错误/审核拦截)不会重试,重试也没用。
返回格式optCOMBOdefaultdefault=不发送该字段(官方接口必须用这个:官方 GPT-Image 恒返回 base64,发送此字段反而会 400)。 b64_json=要求图片以内联 base64 返回:仅用于「只回图片 url 的兼容网关」——可绕开网关图床,解决『图已生成但下载失败(504)』以及 数量>1 时更容易失败的问题。 url=要求返回链接(一般不需要)。

Outputs (1)

NameTypeDescription
图像IMAGE—