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.
📎 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.
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-all",
"prompt": "Change the background to a seaside sunset",
"response_format": "url"
},
files=[
("image[]", ("photo.png", f, "image/png"))
],
timeout=120
).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-all",
"prompt": "Put the person from image1 into the scene of image2, using the art style of image3",
"response_format": "b64_json"
},
files=[
("image[]", ("ref1.png", f1, "image/png")),
("image[]", ("ref2.png", f2, "image/png")),
("image[]", ("ref3.png", f3, "image/png"))
],
timeout=120
).json()
# b64_json already includes the "data:image/png;base64," prefix
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-all" \
-F "prompt=Change the background to a seaside sunset" \
-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-all" \
-F "prompt=Put the person from image1 into the scene of image2, using the art style of image3" \
-F "response_format=b64_json" \
-F "image[]=@./ref1.png" \
-F "image[]=@./ref2.png" \
-F "image[]=@./ref3.png"
import fs from 'node:fs';
const form = new FormData();
form.append('model', 'gpt-image-2-all');
form.append('prompt', 'Change the background to outer space');
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-all');
form.append('prompt', 'Fuse these images into one poster');
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 Quick Reference
| Field | Type | Required | Description |
|---|
model | text | Yes | Fixed: gpt-image-2-all |
prompt | text | Yes | Natural-language edit/fusion instruction |
image[] | file | Yes | Reference image; can be repeated |
response_format | text | No | url (default) or b64_json |
Multi-turn iteration: Feed the previous output image back as image[] input with new instructions to iteratively refine the result.
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 contains the data:image/png;base64, prefix and can be used directly. Do not manually prepend the prefix.
API Key from the API易 Console
model
enum<string>
default:gpt-image-2-all
required
Model name, fixed to gpt-image-2-all
Available options:
gpt-image-2-all
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"
Reference images, can be repeated. Recommended ≤ 10MB per image, formats png/jpg/webp
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
Image successfully generated
Result array (this model returns 1 image per call)