Image editing: edit reference images (1–5)
curl --request POST \
--url https://api.apiyi.com/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=MAI-Image-2.6-Flash \
--form 'prompt=Change the teapot to a deep cobalt blue glaze, keep everything else identical' \
--form 'image=@example-file;type=image/png'import requests
url = "https://api.apiyi.com/v1/images/edits"
files = { "image": ("example-file", open("example-file", "rb"), "image/png") }
payload = {
"model": "MAI-Image-2.6-Flash",
"prompt": "Change the teapot to a deep cobalt blue glaze, keep everything else identical"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'MAI-Image-2.6-Flash');
form.append('prompt', 'Change the teapot to a deep cobalt blue glaze, keep everything else identical');
form.append('image', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.apiyi.com/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"created": 1791000788,
"data": [
{
"b64_json": "<string>"
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000
}
}MAI-Image 2.6 이미지 생성 및 편집
이미지 편집 API 레퍼런스
라이브 플레이그라운드가 포함된 MAI-Image 2.6 이미지 편집 API 레퍼런스 — 편집하거나 결합할 참조 이미지 1~5개와 지침을 업로드하며, multipart/form-data 파일 업로드만 지원합니다. 참조 이미지 수는 가격에 영향을 주지 않습니다
POST
/
v1
/
images
/
edits
Image editing: edit reference images (1–5)
curl --request POST \
--url https://api.apiyi.com/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=MAI-Image-2.6-Flash \
--form 'prompt=Change the teapot to a deep cobalt blue glaze, keep everything else identical' \
--form 'image=@example-file;type=image/png'import requests
url = "https://api.apiyi.com/v1/images/edits"
files = { "image": ("example-file", open("example-file", "rb"), "image/png") }
payload = {
"model": "MAI-Image-2.6-Flash",
"prompt": "Change the teapot to a deep cobalt blue glaze, keep everything else identical"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'MAI-Image-2.6-Flash');
form.append('prompt', 'Change the teapot to a deep cobalt blue glaze, keep everything else identical');
form.append('image', '<string>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.apiyi.com/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/edits")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nMAI-Image-2.6-Flash\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nChange the teapot to a deep cobalt blue glaze, keep everything else identical\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"example-file\"\r\nContent-Type: image/png\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"created": 1791000788,
"data": [
{
"b64_json": "<string>"
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000
}
}오른쪽의 대화형 플레이그라운드는 로컬 이미지 업로드를 지원합니다. Authorization에 API 키를 입력하고(형식:
Bearer sk-xxx), 하나 이상의 image 파일을 선택한 다음 prompt 및 model을 입력하고 전송합니다.🔴 이 엔드포인트는 이미지 URL은 입력으로 지원되지 않습니다. URL만 있는 경우 먼저 서버에서 다운로드한 후 파일을 업로드합니다. 파일 업로드에는 이미지 호스팅이 필요하지 않으며, 로컬 파일을 전송하기만 하면 됩니다.
multipart/form-data 파일 업로드만 허용합니다image을 URL, 데이터 URI 또는 원시 base64로 지정하여 /v1/images/edits에 JSON을 전송하면 400이 반환됩니다.request Content-Type isn't multipart/form-data
사용 사례: 이 페이지는 참조 이미지를 사용한 편집을 위한 것으로, 단일 이미지 편집과 1~5개 이미지 융합을 지원합니다. 텍스트만으로 생성하려면 텍스트-이미지 API를 사용합니다.
🖼️ 1~5개의 참조 이미지 지원(2026-10-07부터)
- 방법:
image[]필드를 이미지 하나당 하나씩 반복합니다. OpenAI SDK에서는 목록을 전달합니다:client.images.edit(image=[f1, f2, ...]).image을 반복해도 작동합니다 - 순서: 이미지는 업로드 순서대로 번호가 지정되므로(이미지 1, 이미지 2, …), 프롬프트에 이미지 2의 여우를 이미지 1에 넣으라고 지정할 수 있습니다
- 가격: 요청당 과금되며 이미지 1개와 이미지 5개의 비용은 동일합니다
- 형식: JPEG, PNG, WebP를 지원하며 GIF 및 기타 형식은 400을 반환합니다
- 이미지 5개 초과 시 400이 반환됩니다
at most 5 reference images are accepted for <model>
image + image2과 같은 번호가 매겨진 필드 이름은 사용하지 마십시오: 요청은 200을 반환하지만 첫 번째 이미지만 사용되고 두 번째 이미지는 삭제됩니다. image1 + image2은 500을 반환합니다 image is required. 여러 이미지의 경우 항상 image[]을 반복하십시오.텍스트-이미지와 동일하게 금지된 매개변수:
response_format, seed 또는 negative_prompt을 전송하지 마십시오(400). 응답은 항상 data[0].b64_json(PNG)입니다.코드 예시
Python (OpenAI SDK · 단일 이미지)
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1",
timeout=180.0
)
# images.edit uses a multipart file upload under the hood; do not pass response_format
resp = client.images.edit(
model="MAI-Image-2.6-Flash",
image=open("teaset.jpg", "rb"),
prompt="Change the teapot to a deep cobalt blue glaze, keep everything else identical"
)
with open("edited.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Python (OpenAI SDK · 다중 이미지 융합)
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1",
timeout=180.0
)
# Pass a list of 1-5 files; the SDK uploads each one as an image[] field
# Images are numbered in upload order (image 1, image 2, ...); same price as a single image
resp = client.images.edit(
model="MAI-Image-2.6-Flash",
image=[open("teaset.jpg", "rb"), open("fox.jpg", "rb")],
prompt="Put the fox from image 2 (keeping every detail of its look) into the scene of image 1, sitting next to the tea set; keep everything else in image 1 unchanged"
)
with open("fused.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Python (requests · 단일 이미지)
import base64
import os
import requests
# Pass the file via files=; requests sets multipart/form-data and the boundary for you
# Do not use json=, and do not set Content-Type by hand
with open("teaset.jpg", "rb") as fp:
response = requests.post(
"https://api.apiyi.com/v1/images/edits",
headers={"Authorization": f"Bearer {os.environ['APIYI_API_KEY']}"},
data={
"model": "MAI-Image-2.6",
"prompt": "Change the teapot to a deep cobalt blue glaze, keep everything else exactly the same"
},
files={"image": ("teaset.jpg", fp, "image/jpeg")},
timeout=180
)
response.raise_for_status()
with open("edited.png", "wb") as f:
f.write(base64.b64decode(response.json()["data"][0]["b64_json"]))
image[]를 포함하도록 files를 튜플 목록으로 전달합니다(딕셔너리는 동일한 키를 반복해서 포함할 수 없습니다):
files = [
("image[]", ("teaset.jpg", open("teaset.jpg", "rb"), "image/jpeg")),
("image[]", ("fox.jpg", open("fox.jpg", "rb"), "image/jpeg")),
]
cURL
# Single-image edit: -F means multipart/form-data, @ uploads a local file
curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=MAI-Image-2.6-Flash" \
-F "prompt=Change the teapot to a deep cobalt blue glaze, keep everything else identical" \
-F "[email protected]" \
| python3 -c "import sys,json,base64; open('edited.png','wb').write(base64.b64decode(json.load(sys.stdin)['data'][0]['b64_json']))"
# Edit and change the canvas to 1536×1024 (a different aspect ratio recomposes the image)
curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=MAI-Image-2.6" \
-F "prompt=Turn this tea set into a lifestyle scene on a wooden table, natural light, photorealistic" \
-F "width=1536" \
-F "height=1024" \
-F "[email protected]"
# Multi-image fusion: repeat the image[] field, 1-5 images, numbered in upload order
curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=MAI-Image-2.6-Flash" \
-F "prompt=Put the fox from image 2 (keeping every detail of its look) into the scene of image 1, sitting next to the tea set; keep everything else in image 1 unchanged" \
-F "image[][email protected]" \
-F "image[][email protected]" \
| python3 -c "import sys,json,base64; open('fused.png','wb').write(base64.b64decode(json.load(sys.stdin)['data'][0]['b64_json']))"
Node.js (fetch + FormData)
import fs from 'node:fs';
const form = new FormData();
form.append('model', 'MAI-Image-2.6-Flash');
form.append('prompt', 'Replace the background with a snowy pine forest at night, keep the person unchanged');
form.append('image', new Blob([fs.readFileSync('./photo.jpg')]), 'photo.jpg');
// Multi-image fusion: call form.append('image[]', ...) once per image instead, up to 5
const resp = await fetch('https://api.apiyi.com/v1/images/edits', {
method: 'POST',
// Do not set Content-Type by hand; FormData adds the boundary
headers: { 'Authorization': `Bearer ${process.env.APIYI_API_KEY}` },
body: form,
signal: AbortSignal.timeout(120000)
});
const data = await resp.json();
fs.writeFileSync('edited.png', Buffer.from(data.data[0].b64_json, 'base64'));
매개변수 참조
| 매개변수 | 유형 | 필수 여부 | 기본값 | 설명 |
|---|---|---|---|---|
model | 문자열 | ✅ | — | MAI-Image-2.6 ($0.12/이미지) 또는 MAI-Image-2.6-Flash ($0.06/이미지), 대소문자를 구분합니다 |
prompt | 문자열 | ✅ | — | 편집 지침입니다. 변경할 내용과 그 외의 모든 내용은 동일하게 유지해야 한다는 점을 명시합니다 |
image / image[] | 파일 | ✅ | — | 참조 이미지 파일, 1–5개입니다. 이미지가 하나인 경우 image를 사용하고, 여러 개인 경우 image[] 필드를 반복하며 업로드 순서에 따라 이미지 1…N으로 번호를 지정합니다. JPEG / PNG / WebP를 지원하며, 개수에 따라 가격은 변하지 않습니다 |
width / height | 정수 | ❌ | 원본의 비율을 따릅니다 | 출력 크기이며, 텍스트-이미지 변환과 동일한 규칙이 적용됩니다. 다른 종횡비를 사용하면 이미지가 재구성됩니다 |
n | 정수 | ❌ | 1 | 이미지 수입니다. 이 엔드포인트에서 작동하며, 이미지당 과금됩니다 |
mask | — | — | — | 지원되지 않으며, 400 <model> does not support mask edits을 반환합니다 |
response_formatseednegative_prompt | — | — | — | 400을 반환합니다 |
생략할 때의 출력 크기: 출력은 원본의 종횡비를 따르며 16의 배수로 맞춰집니다. 예를 들어 1344×756 입력은 1360×768이 됩니다. 여러 이미지가 있는 경우 이미지 1이 종횡비를 설정합니다. 구성을 유지해야 하는 로컬 편집에서는
width / height을 전송하지 마십시오.편집 결과 및 프롬프트 작성
편집 엔드포인트는 원본의 구도, 색상 및 세부 사항을 유지하고 프롬프트에서 요청한 부분만 변경합니다.
| 프롬프트 | 결과 |
|---|---|
✅ Change the teapot to a deep cobalt blue glaze, keep everything else exactly the same | 주전자의 색상만 변경되며 라벨과 다른 객체는 픽셀 단위로 동일하게 유지됩니다 |
✅ Turn this photo into a watercolor painting, keep the composition | 스타일은 다시 칠해지지만 구도는 유지됩니다 |
⚠️ Make it look better | 너무 모호하여 변경 범위를 예측할 수 없습니다 |
“나머지는 모두 동일하게 유지”라고 명시적으로 말하는 것이 이 모델에서 가장 효과적인 기법이며, 원본을 최대한 보존합니다.
다중 이미지 융합
이미지 1이 기본 이미지로 사용되며, 다른 참조 이미지의 객체는 프롬프트에 설명된 대로 이미지 1에 배치됩니다. 아래 예시에서는 하나의 요청에 5개의 이미지(차 세트 + 여우 + 고무 오리 + 알람 시계 + 선인장)를 전송하고, 이미지 2의 여우, 이미지 3의 노란색 고무 오리, 이미지 4의 빨간색 빈티지 알람 시계 및 이미지 5의 화분에 심긴 선인장을 이미지 1의 차 테이블 위에 배치하되 각 객체의 외형을 유지하고 이미지 1의 나머지 부분은 변경하지 않도록 요청합니다.
| 프롬프트 | 결과 |
|---|---|
✅ Put the fox from image 2 into the scene of image 1, keep everything else in image 1 unchanged | 업로드 순서에 따라 이미지를 이미지 N으로 지칭합니다. 가장 신뢰할 수 있는 표현입니다 |
✅ 각 이미지의 객체 이름 지정: the yellow rubber duck from image 3, the red alarm clock from image 4 | 이미지가 많을 때 각 객체의 이름을 지정하면 어느 객체도 빠지지 않도록 할 수 있습니다 |
⚠️ Combine these images into one | 기본 이미지나 주제가 지정되지 않아 구도를 예측할 수 없습니다 |
응답 형식
{
"created": 1791000788,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zU..."
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}
응답 필드
b64_json는data:접두사가 없는 일반 base64이며 PNG로 디코딩됩니다.n > 1를 사용하면data배열에 여러 항목이 포함됩니다.data[0]만 읽지 마십시오.url및revised_prompt은 반환되지 않습니다.
usage로 과금을 조정하지 마십시오. 여기에는 플레이스홀더가 포함되어 있으며(prompt_tokens은 항상 이미지 수의 1000배입니다), 편집 비용은 텍스트-이미지와 동일하고 이미지당 과금되며 참조 이미지 수는 가격을 변경하지 않습니다. APIYI 콘솔 청구서가 최종 기준입니다.본문
multipart/form-data
이 페이지가 도움이 되었나요?