curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "seedream-5-0-260128",
"prompt": "Replace the clothing in image 1 with the outfit from image 2."
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "seedream-5-0-260128",
"prompt": "Replace the clothing in image 1 with the outfit from image 2."
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'seedream-5-0-260128',
prompt: 'Replace the clothing in image 1 with the outfit from image 2.'
})
};
fetch('https://api.apiyi.com/v1/images/generations', 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/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'seedream-5-0-260128',
'prompt' => 'Replace the clothing in image 1 with the outfit from image 2.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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/generations"
payload := strings.NewReader("{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}"
response = http.request(request)
puts response.read_body{
"model": "seedream-5-0-260128",
"created": 1768518000,
"data": [
{
"url": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.bytepluses.com/.../image.png",
"b64_json": "<string>",
"size": "2048x2048"
}
],
"usage": {
"generated_images": 1,
"output_tokens": 6240,
"total_tokens": 6240
}
}Справочник API для редактирования изображений
Справочник API и live Playground для редактирования изображений Seedream, многoизображенческой фузии и пакетной генерации последовательностей — тот же endpoint generations, переключение через массив изображений и параметр sequential_image_generation
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "seedream-5-0-260128",
"prompt": "Replace the clothing in image 1 with the outfit from image 2."
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "seedream-5-0-260128",
"prompt": "Replace the clothing in image 1 with the outfit from image 2."
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'seedream-5-0-260128',
prompt: 'Replace the clothing in image 1 with the outfit from image 2.'
})
};
fetch('https://api.apiyi.com/v1/images/generations', 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/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'seedream-5-0-260128',
'prompt' => 'Replace the clothing in image 1 with the outfit from image 2.'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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/generations"
payload := strings.NewReader("{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"seedream-5-0-260128\",\n \"prompt\": \"Replace the clothing in image 1 with the outfit from image 2.\"\n}"
response = http.request(request)
puts response.read_body{
"model": "seedream-5-0-260128",
"created": 1768518000,
"data": [
{
"url": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.bytepluses.com/.../image.png",
"b64_json": "<string>",
"size": "2048x2048"
}
],
"usage": {
"generated_images": 1,
"output_tokens": 6240,
"total_tokens": 6240
}
}/v1/images/edits. Редактирование, слияние нескольких изображений и пакетная последовательность выполняются через POST /v1/images/generations. Playground на этой странице обращается к тому же эндпоинту, что и Текст-в-изображение — единственное различие состоит в параметрах image и sequential_image_generation в теле запроса.- Редактирование одного изображения —
image: ["url"]+sequential_image_generation: "disabled" - Слияние нескольких изображений —
image: ["url1", "url2", ...]+disabled - Пакетная последовательность —
sequential_image_generation: "auto"+sequential_image_generation_options.max_images: N - Изображение-в-последовательность — объединяет оба: массив
image+auto+max_images
response_format: "url" по умолчанию Playground работает нормально (в ответе просто временная ссылка BytePlus TOS). Если вы переключитесь на response_format: "b64_json", ответ будет содержать base64-строку размером в несколько МБ, и браузерный Playground может показать 请求时发生错误: unable to complete request — запрос на самом деле выполнен успешно; браузер просто не может отобразить такую длинную base64-строку.Рекомендуемый рабочий процесс:- Просто хотите посмотреть изображение? Оставьте режим
urlпо умолчанию — Playground возвращает ссылку напрямую (не забудьте скачать ее в свое хранилище в течение 24 часов). - Нужен b64_json? Скопируйте пример кода ниже и запустите его локально — код автоматически декодирует и сохранит изображение в файл.
- Нет загрузок multipart/form-data — сначала загрузите свои изображения в OSS или на публичный хост изображений, а затем передайте URL в массиве
image image— это массив URL, а не повторяющееся полеimage[](в отличие от форматаmultipart/form-dataOpenAI)- Нет поля
mask— Seedream не поддерживает inpainting по маске alpha-канала; все изображение переписывается по prompt - Жесткий лимит на общее количество: входные ссылки + выходные изображения ≤ 15
image становится тем, что в prompt обозначается как «изображение 1 / изображение 2 / изображение 3». Явно указывайте порядок:Замените одежду на изображении 1 на наряд с изображения 2, сохранив освещение с изображения 3.Лучше всего работают prompt на английском языке (модель в основном обучена на English), но китайский тоже поддерживается, если формулировка однозначна.
Примеры кода
extra_body (важно — не думайте, что это дополнительный уровень вложенности)image, sequential_image_generation и watermark не являются стандартными параметрами images.generate() OpenAI SDK, поэтому в Python SDK вы должны поместить их внутрь extra_body, чтобы отправить их.Но extra_body — это всего лишь контейнер параметров SDK: его поля расплющиваются и объединяются на верхнем уровне тела запроса, на том же уровне, что и model и prompt. Фактический JSON, который уходит, идентичен примеру cURL ниже (image находится на верхнем уровне); в запросе нет реальной вложенности "extra_body": {...}.Если вы не используете OpenAI SDK и вместо этого собираете JSON напрямую (requests / fetch / и т. д.), не записывайте extra_body — просто поместите image и другие поля на тот же уровень, что и model.Python (OpenAI SDK · редактирование одного изображения)
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="seedream-5-0-260128",
prompt="Generate a close-up image of a dog lying on lush grass.",
size="2K",
response_format="url",
# Fields in extra_body are flattened to the top level of the request body
# (same level as model) by the SDK — not an extra nesting layer
extra_body={
"image": ["https://your-oss.example.com/source-photo.png"],
"sequential_image_generation": "disabled",
"watermark": False,
}
)
print(resp.data[0].url)
Python (OpenAI SDK · объединение нескольких изображений)
resp = client.images.generate(
model="seedream-4-5-251128",
prompt="Replace the clothing in image 1 with the outfit from image 2, keeping the lighting style of image 3.",
size="4K",
response_format="url",
extra_body={
"image": [
"https://your-oss.example.com/person.png",
"https://your-oss.example.com/outfit.png",
"https://your-oss.example.com/lighting-ref.png",
],
"sequential_image_generation": "disabled",
"watermark": False,
}
)
print(resp.data[0].url)
Python (OpenAI SDK · пакетная последовательность)
resp = client.images.generate(
model="seedream-5-0-260128",
prompt=(
"Generate four cinematic sci-fi storyboard scenes:"
"Scene 1 — astronaut repairing a spacecraft;"
"Scene 2 — meteor strike in deep space;"
"Scene 3 — emergency dodge in zero gravity;"
"Scene 4 — astronaut returning to ship."
),
size="2K",
response_format="url",
extra_body={
"sequential_image_generation": "auto",
"sequential_image_generation_options": {"max_images": 4},
"watermark": False,
}
)
for item in resp.data:
print(item.url)
cURL (объединение нескольких изображений)
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-5-0-260128",
"prompt": "Replace the clothing in image 1 with the outfit from image 2.",
"image": [
"https://your-oss.example.com/person.png",
"https://your-oss.example.com/outfit.png"
],
"sequential_image_generation": "disabled",
"size": "2K",
"response_format": "url",
"watermark": false
}'
Node.js (fetch · пакетная последовательность)
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'seedream-5-0-260128',
prompt: 'A four-panel comic about a cat astronaut: launch, space walk, alien encounter, return home.',
size: '2K',
sequential_image_generation: 'auto',
sequential_image_generation_options: { max_images: 4 },
response_format: 'url',
watermark: false
})
});
const { data } = await resp.json();
data.forEach((item, i) => console.log(`#${i + 1}:`, item.url));
Справочник параметров
| Параметр | Тип | Обязательное | Значение по умолчанию | Описание |
|---|---|---|---|---|
model | string | да | — | seedream-5-0-260128 / seedream-4-5-251128 / seedream-4-0-250828 / seedream-5-0-pro-260628 (уровень Pro, $0.12/запрос) |
prompt | string | да | — | Инструкция для редактирования / fusion / sequence |
image | array of string | требуется для редактирования | — | Справочные изображения в виде URL или base64 data URI (data:image/jpeg;base64,..., проверенные), до 10 (согласно официальной документации 4.5 / 5.0-pro) |
sequential_image_generation | string | нет | disabled | disabled для одиночного вывода; auto для пакетной последовательности. Не принимается 5.0-pro: любое значение (включая disabled) возвращает 400 — полностью опустите параметр с pro |
sequential_image_generation_options.max_images | integer | нет | — | Действует только с auto. Ограничено input + output ≤ 15. Также не принимается 5.0-pro |
size | string | нет | 2K | Предустановленный уровень или точные пиксели — поддержка уровней зависит от версии (см. Обзор) |
response_format | string | нет | url | url / b64_json |
output_format | string | нет | jpeg | 5.0 / 5.0-pro поддерживают png / jpeg; 4.5 / 4.0 только jpeg |
watermark | boolean | нет | зависит | Установите false для коммерческого использования |
stream | boolean | нет | false | Потоковый вывод, рекомендуется для длинных prompt. Не принимается 5.0-pro — возвращает 400 |
Ограничения по количеству в режимах Multi-image и последовательности
| Сценарий | Количество входных image | max_images | Фактический результат | Суммарное ограничение |
|---|---|---|---|---|
| Редактирование одного изображения | 1 | — | 1 | 2 ≤ 15 ✅ |
| Слияние нескольких изображений | 3 | — | 1 | 4 ≤ 15 ✅ |
| Слияние нескольких изображений + последовательность | 3 | 4 | 4 | 7 ≤ 15 ✅ |
| Слияние нескольких изображений + последовательность | 10 | 6 | 6 | 16 > 15 ❌ отклонено |
Формат ответа
{
"model": "seedream-5-0-260128",
"created": 1768518000,
"data": [
{
"url": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.bytepluses.com/seedream-5-0/.../scene-1.png",
"size": "2048x2048"
},
{
"url": "https://...scene-2.png",
"size": "2048x2048"
}
],
"usage": {
"generated_images": 2,
"output_tokens": 12480,
"total_tokens": 12480
}
}
data отражает фактическое количество выводаsequential_image_generation: "disabled"→ массив из одного элементаdatasequential_image_generation: "auto"+max_images: N→ обычно N элементов (иногда меньше, если prompt возвращает меньше)- Тарификация производится по
usage.generated_images, а не поmax_images
Авторизации
API Key obtained from APIYI Console
Тело
Model ID
seedream-5-0-260128, seedream-5-0-lite-260128, seedream-4-5-251128, seedream-4-0-250828, seedream-5-0-pro-260628 Editing / fusion / sequence instruction. For multi-image scenarios, refer to images explicitly as 'image 1 / image 2'
"Replace the clothing in image 1 with the outfit from image 2."
Reference image URL array. Up to 10 images (per official 4.5 docs). Note: input + output count ≤ 15
10[
"https://your-oss.example.com/person.png",
"https://your-oss.example.com/outfit.png"
]
Generation mode switch. disabled = single output (default); auto = batch sequence, paired with max_images
disabled, auto Batch sequence options. Effective only when sequential_image_generation=auto
Show child attributes
Show child attributes
Output size. Preset tiers (vary by version):
1K(4.0 only) /2K(all) /3K(5.0 only) /4K(4.5, 4.0)
Or exact pixel size WxH, total pixels ∈ [1280×720, 4096×4096], aspect ratio ∈ [1/16, 16]
"2K"
url, b64_json Output format. 5.0 supports png/jpeg; 4.5/4.0 only jpeg
png, jpeg Streaming output. Recommended for long prompts and multi-image sequence scenarios
Ответ
Edited image generated successfully
"seedream-5-0-260128"
1768518000
Result array. disabled mode returns 1 element; auto mode typically returns max_images elements (may be fewer)
Show child attributes
Show child attributes
Billed by generated_images actual count, NOT by max_images
Show child attributes
Show child attributes
Была ли эта страница полезной?