Skip to main content
POST
Image editing: edit or fuse reference images with instructions
The interactive Playground on the right supports direct local file upload. Enter your API Key in the Authorization field (format: Bearer sk-xxx), select images, fill in prompt and model, then click send.
Scope: This page is for editing or fusing one or more reference images. Requests use multipart/form-data. For pure text-to-image generation, use the Text-to-Image endpoint.
🖥️ Browser Playground limitation (default b64_json mode)This endpoint defaults to response_format: "b64_json", so the response carries a multi-MB base64 string and the browser Playground may show 请求时发生错误: unable to complete requestthe request actually succeeded; the browser just can’t render such a long base64 string.Recommended workflow:
  • Just want to view the image in the Playground? Pass "response_format": "url" explicitly — the response is a single R2 link and renders fine.
  • Want base64 or uploading large reference images? Copy the code sample below and run it locally — the code handles upload and decoding automatically.
📎 Multi-image order mattersThe image field can be repeated to upload multiple reference images. The order determines how “image1/image2/image3” in the prompt are resolved. We recommend referring to them explicitly, e.g.:
Put the person from image1 into the scene of image2, using the art style of image3
Recommended ≤ 10MB per image, formats png / jpg / webp. Overly large images may hit gateway limits.
🎯 Shape-preserving edits: This endpoint’s output aspect ratio follows whichever reference image the prompt names as the edit targetnot necessarily the first one in multi-image scenarios.For example, with the prompt “modify image2, change image2’s outfit and hat to match image1”, if image2 is 1:1, the output is 1:1 (even if image1 is a landscape 16:9).Useful for outfit swaps, adding accessories, retouching, and other shape-preserving edits. The size field has no effect on this model (sending any value is silently ignored — for strict size locking, use gpt-image-2-vip). If the prompt doesn’t pick a target, the model decides on its own.

Code Examples

Python

Single-image edit:
Multi-image fusion:

cURL

Single-image edit:
Multi-image fusion:

Node.js (native fetch + FormData)

Browser JavaScript (File objects)

Parameters Quick Reference

Multi-turn iteration: Feed the previous output image back as image input with new instructions to iteratively refine the result.

Response Format

Same as the text-to-image endpoint: data[0] returns either url or b64_json — never both (depends on response_format). This endpoint defaults to b64_json. b64_json mode (default):
url mode (requires explicit "response_format": "url"):
Verified July 2026: the b64_json field is raw base64 without the data: prefix — decode it or prepend the prefix yourself before rendering. Earlier versions did include the prefix, so always check startsWith('data:') first to handle both shapes.

Authorizations

Authorization
string
header
required

API Key from the API易 Console

Body

multipart/form-data
model
enum<string>
default:gpt-image-2-all
required

Model name, fixed to gpt-image-2-all

Available options:
gpt-image-2-all
prompt
string
required

Edit/fusion instruction. For multi-image fusion, reference upload order as image1/image2/image3

Example:

"Put the person from image1 into the scene of image2, using the art style of image3"

image
file[]
required

Reference images. For a single image, send the field once; for multiple images, repeat the same image field (e.g., -F [email protected] -F [email protected]) — upload order maps to image1 / image2 / ... in the prompt. Recommended ≤ 10MB each, formats png / jpg / webp.

response_format
enum<string>
default:b64_json

Response format. b64_json returns a base64 string already prefixed with a data URL header (default); url returns an R2 CDN link

Available options:
b64_json,
url

Response

Image successfully generated. Defaults to base64 in data[0].b64_jsonurl is not returned in the same response.

Image editing response. data[0] returns either url or b64_json, never both (depends on response_format; this endpoint defaults to b64_json).

data
object[]

Result array (this model returns 1 image per call)

created
integer

Unix timestamp (seconds)

usage
object

Token usage statistics