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 リファレンス
Seedream の画像編集、複数画像の融合、バッチ連続生成の API リファレンスとライブ プレイグラウンド — 画像配列と sequential_image_generation パラメータで切り替える、同じ generations エンドポイント
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 で行われます。このページのプレイグラウンドは テキストから画像生成 と同じエンドポイントを呼び出します — 唯一の違いは、リクエスト本文内の 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 - 画像からシーケンス — 2 つを組み合わせます:
image配列 +auto+max_images
response_format: "url" モードでは、Playground は問題なく動作します(レスポンスは一時的な BytePlus TOS リンクだけです)。response_format: "b64_json" に切り替えると、レスポンスに数 MB の base64 文字列が含まれ、ブラウザ版 Playground では 请求时发生错误: unable to complete request と表示されることがあります — リクエスト自体は実際には成功しています。ブラウザがそのような長い base64 文字列をレンダリングできないだけです。推奨ワークフロー:- 画像を表示したいだけですか? デフォルトの
urlモードのままにしてください — Playground はリンクを直接返します(24 時間以内にご自身のストレージへダウンロードしてください)。 - b64_json が必要ですか? 下のコードサンプルをコピーしてローカルで実行してください — コードが画像をデコードしてファイルに自動保存します。
- multipart/form-data アップロードは不要です — まず画像を OSS か公開画像ホストにアップロードし、その後
image配列に URL を渡します imageは URL 配列であり、繰り返しのimage[]フィールドではありません(OpenAI のmultipart/form-data形式とは異なります)maskフィールドはありません — Seedream はアルファチャンネルマスクのインペインティングをサポートしておらず、画像全体が prompt によって書き換えられます- 合計数には厳しい上限があります: 入力参照 + 出力 ≤ 15 枚の画像
image 配列内の URL の順序が、prompt で参照される「画像 1 / 画像 2 / 画像 3」になります。順序を明示してください:画像 1 の服を画像 2 の衣装に置き換え、画像 3 の照明は維持してください。英語の prompt が最も効果的です(モデルは主に英語で学習されています)が、表現が明確であれば中国語もサポートされています。
コード例
extra_body について(重要 — 追加のネスト層だと誤解しないでください)image、sequential_image_generation、および watermark は、OpenAI SDK の images.generate() の標準パラメータではないため、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));
パラメータリファレンス
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | yes | — | seedream-5-0-260128 / seedream-4-5-251128 / seedream-4-0-250828 / seedream-5-0-pro-260628 (pro tier, $0.12/request) |
prompt | string | yes | — | 編集 / フュージョン / シーケンス指示 |
image | array of string | 編集時必須 | — | URLまたはbase64 data URIとしての参照画像(data:image/jpeg;base64,...、検証済み)、最大10枚(公式4.5 / 5.0-proドキュメント準拠) |
sequential_image_generation | string | no | disabled | 単一出力用の disabled; バッチシーケンス用の auto。5.0-proでは未対応: どの値でも(disabledを含む)400を返します — proではパラメータを完全に省略してください |
sequential_image_generation_options.max_images | integer | no | — | auto の場合のみ有効。input + output ≤ 15 が適用されます。5.0-proでも未対応 |
size | string | no | 2K | プリセットティアまたは正確なピクセル数 — ティアのサポートはバージョンによって異なります(Overviewを参照) |
response_format | string | no | url | url / b64_json |
output_format | string | no | jpeg | 5.0 / 5.0-pro は png / jpeg をサポートし、4.5 / 4.0 は jpeg のみ |
watermark | boolean | no | varies | 商用利用には false を設定します |
stream | boolean | no | false | ストリーミング出力。長い prompt に推奨されます。5.0-proでは未対応 — 400を返します |
複数画像およびシーケンスモードにおけるカウント制約
| シナリオ | 入力 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
このページは役に立ちましたか?