Skip to main content
POST
Image editing: edit or fuse reference images with locked output size
The interactive Playground on the right supports direct local image upload. Enter your API Key in the Authorization field (format: Bearer sk-xxx), pick the image, set prompt / model / size, then click send.
Scope: This page is for editing or fusing one or more reference images. The request uses multipart/form-data. For pure text-to-image, see the Text-to-Image endpoint.Difference vs gpt-image-2-all: identical call structure, just one extra size field. If you don’t need to lock dimensions and want fastest output, use gpt-image-2-all.
🖥️ Browser Playground limitationThis endpoint returns a base64 string (b64_json) by default, which can be several MB, so 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: when you want base64 or need to upload very large reference images, copy the code sample below and run it locally.
📎 Multi-image fusion order mattersThe image field accepts multiple reference images. The order is the basis for “image1 / image2 / image3” references in your prompt. Reference them explicitly in the prompt, e.g.:
Place the person from image1 into the scene of image2, in the painting style of image3
Recommended ≤ 10MB per image, formats png / jpg / webp. Overly large images may hit gateway limits.
🎯 Shape-preserving edits: When you pass size=auto (or omit size), the output inherits the aspect ratio of 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. If the prompt doesn’t pick a target, the model decides on its own; pass an explicit 30-bucket size only when you need to change the aspect ratio.
⚠️ Key parameter notes
  • size: for editing, prefer auto (or omit the field) — the model preserves the aspect ratio of whichever reference image the prompt names as the target of the edit, not necessarily the first one in multi-image scenarios. For example, with the prompt “modify image2, change image2’s outfit to match image1”, the output ratio matches image2; if the prompt doesn’t disambiguate, the model decides on its own. To force a different dimension, pick one of the 30 supported sizes; use lowercase ASCII x, e.g., 2048x1360, 3840x2160. Full table: overview page.
  • quality: ❌ rejected — do not pass.
  • n: ❌ rejected — single image per call.
  • response_format: omitting it returns base64 (raw, no prefix, verified July 2026); pass "url" for an image URL. Businesses that depend on URL output should switch their token to the image2_OSS group for deterministic URL output with no base64 fallback.

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

Multi-turn iteration: feed the previous output back as the next call’s image with a new edit instruction to refine progressively. Each round can specify its own size.

Response Format

Same as the text-to-image endpoint: returns base64 by default (data[0].b64_json, raw base64 with no prefix, verified July 2026). For an image URL, pass response_format: "url" explicitly; businesses that depend on URL output should switch their token to the image2_OSS group for deterministic URL output with no base64 fallback. data[0] returns either url or b64_json — never both. b64_json mode (default):
url mode (pass response_format: "url" explicitly; use the image2_OSS group if you depend on URLs):
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.

Model Overview (full size table)

Complete 30-size table, pricing, technical specs

Text-to-Image API

/v1/images/generations compatible endpoint

Sister model gpt-image-2-all

Same call format when you don’t need locked size — faster output

Authorizations

Authorization
string
header
required

API Key from the API易 Console

Body

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

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

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

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

Example:

"Place the person from image1 into the scene of image2, in the 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 image=@a.png -F image=@b.png) — upload order maps to image1 / image2 / ... in the prompt. Recommended ≤ 10MB each, formats png / jpg / webp.

size
enum<string>

Output size. For editing, prefer auto (or omit the field) — the model preserves the aspect ratio of whichever reference image the prompt names as the target of the edit (not necessarily the first one in multi-image scenarios). For example, with the prompt "modify image2, change image2's outfit to match image1", the output ratio matches image2. If the prompt doesn't disambiguate, the model decides on its own. To force a different dimension, pick one of the 30 supported sizes; format: WIDTHxHEIGHT with lowercase ASCII x, e.g., 2048x1360, 3840x2160. Flat $0.03/image across all tiers.

Available options:
auto,
1280x1280,
848x1280,
1280x848,
960x1280,
1280x960,
1024x1280,
1280x1024,
720x1280,
1280x720,
1280x544,
2048x2048,
1360x2048,
2048x1360,
1536x2048,
2048x1536,
1632x2048,
2048x1632,
1152x2048,
2048x1152,
2048x864,
2880x2880,
2336x3520,
3520x2336,
2480x3312,
3312x2480,
2560x3216,
3216x2560,
2160x3840,
3840x2160,
3840x1632
Example:

"2048x1360"

Response

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

Image editing response. Returns base64 by default (data[0].b64_json); to get a url, switch to the image2_OSS group with response_format=url. data[0] returns either url or b64_json, never both.

data
object[]

Result array (this model returns 1 image per call)

created
integer

Unix timestamp (seconds)

usage
object

Token usage statistics