Skip to main content
POST
/
v1
/
images
/
edits
Image editing: edit or fuse reference images with locked output size
curl --request POST \
  --url https://api.apiyi.com/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form model=gpt-image-2-vip \
  --form 'prompt=Place the person from image1 into the scene of image2, in the style of image3' \
  --form 'image[]=<string>' \
  --form image[].items='@example-file'
{
  "data": [
    {
      "url": "https://r2cdn.copilotbase.com/r2cdn2/00aaa9fb-756c-4119-a4a0-4a44fc75152b.png",
      "b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt

Use this file to discover all available pages before exploring further.

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 limitation (b64_json mode only)In the default response_format: "url" mode, the Playground works fine (the response is just an R2 link). If you switch to response_format: "b64_json", the response contains 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? Keep the default url mode — the Playground returns the link directly.
  • Need b64_json or want 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.
⚠️ Key parameter notes
  • size: must be 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.

Code Examples

Python

Single-image edit:
import requests

API_KEY = "sk-your-api-key"

with open("photo.png", "rb") as f:
    response = requests.post(
        "https://api.apiyi.com/v1/images/edits",
        headers={"Authorization": f"Bearer {API_KEY}"},
        data={
            "model": "gpt-image-2-vip",
            "prompt": "Replace the background with a sunset beach",
            "size": "2048x1360",          # 3:2 2K Recommended
            "response_format": "url"
        },
        files=[
            ("image[]", ("photo.png", f, "image/png"))
        ],
        timeout=300  # conservative; absorbs upload + long-tail
    ).json()

print(response["data"][0]["url"])
Multi-image fusion:
import requests

with open("ref1.png", "rb") as f1, \
     open("ref2.png", "rb") as f2, \
     open("ref3.png", "rb") as f3:
    response = requests.post(
        "https://api.apiyi.com/v1/images/edits",
        headers={"Authorization": "Bearer sk-your-api-key"},
        data={
            "model": "gpt-image-2-vip",
            "prompt": "Place the person from image1 into the scene of image2, in the style of image3",
            "size": "2048x2048",          # 1:1 2K Recommended
            "response_format": "b64_json"
        },
        files=[
            ("image[]", ("ref1.png", f1, "image/png")),
            ("image[]", ("ref2.png", f2, "image/png")),
            ("image[]", ("ref3.png", f3, "image/png"))
        ],
        timeout=300
    ).json()

# b64_json already prefixed — use directly as <img src>
data_url = response["data"][0]["b64_json"]

cURL

Single-image edit:
curl -X POST "https://api.apiyi.com/v1/images/edits" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "model=gpt-image-2-vip" \
  -F "prompt=Replace the background with a sunset beach" \
  -F "size=2048x1360" \
  -F "response_format=url" \
  -F "image[]=@./photo.png"
Multi-image fusion:
curl -X POST "https://api.apiyi.com/v1/images/edits" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "model=gpt-image-2-vip" \
  -F "prompt=Place the person from image1 into the scene of image2, in the style of image3" \
  -F "size=2048x2048" \
  -F "response_format=b64_json" \
  -F "image[]=@./ref1.png" \
  -F "image[]=@./ref2.png" \
  -F "image[]=@./ref3.png"

Node.js (native fetch + FormData)

import fs from 'node:fs';

const form = new FormData();
form.append('model', 'gpt-image-2-vip');
form.append('prompt', 'Replace the background with outer space');
form.append('size', '2048x1360');
form.append('response_format', 'url');
form.append(
  'image[]',
  new Blob([fs.readFileSync('./photo.png')]),
  'photo.png'
);

const resp = await fetch('https://api.apiyi.com/v1/images/edits', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer sk-your-api-key' },
    body: form
});
const data = await resp.json();
console.log(data.data[0].url);

Browser JavaScript (File objects)

// <input type="file" id="fileInput" multiple>
const files = document.getElementById('fileInput').files;
const form = new FormData();
form.append('model', 'gpt-image-2-vip');
form.append('prompt', 'Fuse these images into a single poster');
form.append('size', '2048x2048');
form.append('response_format', 'url');
for (const f of files) form.append('image[]', f);

const resp = await fetch('https://api.apiyi.com/v1/images/edits', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer sk-your-api-key' },
    body: form
});
const { data } = await resp.json();
document.getElementById('result').src = data[0].url;

Parameters

FieldTypeRequiredDescription
modeltextYesFixed at gpt-image-2-vip
prompttextYesNatural-language edit/fusion description
image[]fileYesReference image; can be repeated (array field)
sizetextStrongly recommendedOutput size from the 30-size set; format WIDTHxHEIGHT (lowercase x)
response_formattextNourl (default) or b64_json
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: url mode:
{
    "data": [
        {
            "url": "https://r2cdn.copilotbase.com/r2cdn2/xxxxx.png"
        }
    ]
}
b64_json mode:
{
    "data": [
        {
            "b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
        }
    ]
}
The b64_json field already includes the data:image/png;base64, prefix. Use it directly. Do not prepend the prefix again.

Model Overview (full size table)

Complete 30-size table, pricing, technical specs

Chat API

Chat Completions format with online URL inputs

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 image(s), can be repeated. Recommended ≤ 10MB each, formats png/jpg/webp

size
enum<string>

Output size, picked from the 30-size set. Format: WIDTHxHEIGHT with lowercase ASCII x, e.g., 2048x1360, 3840x2160. Flat $0.03/image across all tiers.

Available options:
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_format
enum<string>
default:url

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

Available options:
url,
b64_json

Response

Image successfully generated

data
object[]

Result array (this model returns 1 image per call)