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