Skip to main content
POST
Image editing: edit reference images (1–5)
The interactive Playground on the right supports uploading local images. Enter your API key under Authorization (format: Bearer sk-xxx), pick one or more image files, fill in prompt and model, and send.
🔴 This endpoint only accepts multipart/form-data file uploadsSending JSON to /v1/images/edits (with image as a URL, data URI, or raw base64) returns 400:
Image URLs are not supported as input. If you only have a URL, download it on your server first, then upload the file. File upload needs no image hosting; just send the local file.
Use case: this page is for editing with reference images, covering single-image edits and fusing 1–5 images. To generate from text only, use the Text-to-Image API.
🖼️ 1–5 reference images supported (since 2026-10-07)
  • How: repeat the image[] field, one image per field. With the OpenAI SDK, pass a list: client.images.edit(image=[f1, f2, ...]). Repeating image also works
  • Order: images are numbered in upload order (image 1, image 2, …), so the prompt can say “put the fox from image 2 into image 1”
  • Price: billed per request; 1 image or 5 images costs the same
  • Formats: JPEG, PNG, WebP; GIF and other formats return 400
  • More than 5 images returns 400 at most 5 reference images are accepted for <model>
Do not use numbered field names such as image + image2: the request returns 200 but only the first image is used; the second is dropped. image1 + image2 returns 500 image is required. For several images, always repeat image[].
Same forbidden parameters as text-to-image: do not send response_format, seed, or negative_prompt (400). The response is always data[0].b64_json (PNG).

Code Examples

Python (OpenAI SDK · single image)

Python (OpenAI SDK · multi-image fusion)

Python (requests · single image)

For several images, pass files as a list of tuples with one image[] per image (a dict cannot hold repeated keys):

cURL

Node.js (fetch + FormData)

Parameter Reference

Output size when you omit it: the output follows the original’s aspect ratio snapped to multiples of 16, e.g. a 1344×756 input gives 1360×768; with several images, image 1 sets the aspect ratio. For local edits that should keep the composition, do not send width / height.

Editing Results and Prompting

The editing endpoint keeps the original’s composition, colors, and details and only changes what the prompt asks for:
MAI-Image-2.6-Flash editing example: teapot recolored from cream to cobalt blue, everything else unchanged
Explicitly saying “keep everything else the same” is the most effective technique with this model and preserves as much of the original as possible.

Multi-Image Fusion

Image 1 serves as the base, and objects from the other reference images are placed into it as the prompt describes. The example below sends 5 images in one request (tea set + fox + rubber duck + alarm clock + cactus), with a prompt asking to place the fox from image 2, the yellow rubber duck from image 3, the red vintage alarm clock from image 4 and the potted cactus from image 5 onto the tea table in image 1, keeping each object’s look and leaving the rest of image 1 unchanged:
MAI-Image-2.6-Flash multi-image fusion example: 5 reference images in, all four objects placed into the tea set image with the rest unchanged

Response Format

Response fields
  • b64_json is plain base64 without a data: prefix and decodes to a PNG.
  • With n > 1 the data array has several items; don’t read only data[0].
  • No url and no revised_prompt are returned.
Do not reconcile billing with usage: it holds placeholders (prompt_tokens is always 1000 × the image count). Editing costs the same as text-to-image, billed per image, and the number of reference images does not change the price; the APIYI console bill is authoritative.

Authorizations

Authorization
string
header
required

API key from the APIYI console

Body

multipart/form-data
model
enum<string>
default:MAI-Image-2.6-Flash
required

Model ID (case-sensitive)

Available options:
MAI-Image-2.6-Flash,
MAI-Image-2.6
prompt
string
required

Edit instruction. State what to change and that everything else stays the same

Example:

"Change the teapot to a deep cobalt blue glaze, keep everything else identical"

image
file[]
required

Reference image files, 1–5, numbered image 1…N in upload order. png / jpg / webp. In code, repeat the image[] field for several images

Required array length: 1 - 5 elements
width
integer

Optional output width. Same rules as text-to-image: each side ≥ 768, width × height ≤ 2,359,296, sent together with height

Required range: x >= 768
height
integer

Optional output height, same rules as width

Required range: x >= 768
n
integer
default:1

Number of images. Works on this endpoint, billed per image

Required range: x >= 1
Example:

1

Response

Image generated

created
integer

Creation timestamp

Example:

1791000788

data
object[]

Image results; length equals n

usage
object

Placeholder values, not for billing reconciliation. prompt_tokens is always 1000 × images