Seedream 图片生成(官方协议)
curl --request POST \
--globoff \
--url 'https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image": [
"<string>"
],
"size": "<string>",
"response_format": "<string>",
"watermark": true,
"stream": true,
"sequential_image_generation": "<string>",
"sequential_image_generation_options": {},
"optimize_prompt_options": {},
"output_format": "<string>",
"background": "<string>",
"tools": [
{}
],
"layer_decomposition": true,
"seed": 123,
"guidance_scale": 123
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"image": ["<string>"],
"size": "<string>",
"response_format": "<string>",
"watermark": True,
"stream": True,
"sequential_image_generation": "<string>",
"sequential_image_generation_options": {},
"optimize_prompt_options": {},
"output_format": "<string>",
"background": "<string>",
"tools": [{}],
"layer_decomposition": True,
"seed": 123,
"guidance_scale": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image: ['<string>'],
size: '<string>',
response_format: '<string>',
watermark: true,
stream: true,
sequential_image_generation: '<string>',
sequential_image_generation_options: {},
optimize_prompt_options: {},
output_format: '<string>',
background: '<string>',
tools: [{}],
layer_decomposition: true,
seed: 123,
guidance_scale: 123
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/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.example.com/{{llmApiOrigin}}/seedream/api/v3/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' => '<string>',
'prompt' => '<string>',
'image' => [
'<string>'
],
'size' => '<string>',
'response_format' => '<string>',
'watermark' => true,
'stream' => true,
'sequential_image_generation' => '<string>',
'sequential_image_generation_options' => [
],
'optimize_prompt_options' => [
],
'output_format' => '<string>',
'background' => '<string>',
'tools' => [
[
]
],
'layer_decomposition' => true,
'seed' => 123,
'guidance_scale' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}"
response = http.request(request)
puts response.read_body图像系列
Seedream 图片生成(官方协议)
火山方舟 Seedream 官方协议图片生成入口:同步出图、参考图、组图与流式输出
POST
{llmApiOrigin}
/
seedream
/
api
/
v3
/
images
/
generations
Seedream 图片生成(官方协议)
curl --request POST \
--globoff \
--url 'https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image": [
"<string>"
],
"size": "<string>",
"response_format": "<string>",
"watermark": true,
"stream": true,
"sequential_image_generation": "<string>",
"sequential_image_generation_options": {},
"optimize_prompt_options": {},
"output_format": "<string>",
"background": "<string>",
"tools": [
{}
],
"layer_decomposition": true,
"seed": 123,
"guidance_scale": 123
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"image": ["<string>"],
"size": "<string>",
"response_format": "<string>",
"watermark": True,
"stream": True,
"sequential_image_generation": "<string>",
"sequential_image_generation_options": {},
"optimize_prompt_options": {},
"output_format": "<string>",
"background": "<string>",
"tools": [{}],
"layer_decomposition": True,
"seed": 123,
"guidance_scale": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image: ['<string>'],
size: '<string>',
response_format: '<string>',
watermark: true,
stream: true,
sequential_image_generation: '<string>',
sequential_image_generation_options: {},
optimize_prompt_options: {},
output_format: '<string>',
background: '<string>',
tools: [{}],
layer_decomposition: true,
seed: 123,
guidance_scale: 123
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/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.example.com/{{llmApiOrigin}}/seedream/api/v3/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' => '<string>',
'prompt' => '<string>',
'image' => [
'<string>'
],
'size' => '<string>',
'response_format' => '<string>',
'watermark' => true,
'stream' => true,
'sequential_image_generation' => '<string>',
'sequential_image_generation_options' => [
],
'optimize_prompt_options' => [
],
'output_format' => '<string>',
'background' => '<string>',
'tools' => [
[
]
],
'layer_decomposition' => true,
'seed' => 123,
'guidance_scale' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/seedream/api/v3/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image\": [\n \"<string>\"\n ],\n \"size\": \"<string>\",\n \"response_format\": \"<string>\",\n \"watermark\": true,\n \"stream\": true,\n \"sequential_image_generation\": \"<string>\",\n \"sequential_image_generation_options\": {},\n \"optimize_prompt_options\": {},\n \"output_format\": \"<string>\",\n \"background\": \"<string>\",\n \"tools\": [\n {}\n ],\n \"layer_decomposition\": true,\n \"seed\": 123,\n \"guidance_scale\": 123\n}"
response = http.request(request)
puts response.read_body简介
Seedream 官方入口以火山方舟 Seedream 图片生成协议对外提供服务,从火山官方 API 迁移时只需替换 Base URL。接口为同步调用:一次请求直接返回生成结果,没有任务 ID,也不需要轮询;可选 SSE 流式返回。POST /seedream/api/v3/images/generations
与原 OpenAI 兼容入口 /v1/images/generations 并存,两者计费一致。需要组图、流式、图层拆分、联网搜索等 Seedream 专有能力时使用本入口;已有 OpenAI Images 客户端可以继续使用原入口。
认证
Content-Type 必须为 application/json,不支持 multipart 表单。
支持模型
模型名必须以doubao-seedream- 或 seedream- 开头。常用模型:
| 模型 | 定位 | 参考图上限 | 组图 | 流式 |
|---|---|---|---|---|
doubao-seedream-4-0-250828 | Seedream 4.0 | 14 | 支持 | 支持 |
doubao-seedream-4-5-251128 | Seedream 4.5 | 14 | 支持 | 支持 |
doubao-seedream-5-0-260128 | Seedream 5.0 Lite | 14 | 支持 | 支持 |
doubao-seedream-5-0-pro-260628 | Seedream 5.0 Pro | 10 | 不支持 | 不支持 |
网关按前缀识别新模型,未列出的doubao-seedream-*/seedream-*模型同样可以请求;是否真正可用取决于服务端渠道配置与上游账号开通情况。各模型的参数能力以官方文档为准,请求该模型不支持的参数时会由上游返回错误并原样透传。
请求参数
参考图,支持 http(s) URL 或 base64 数据 URI(
data:image/png;base64,...)。单张可传字符串,多张传数组,最多 14 张。输出尺寸。可传档位(
1K / 1.5K / 2K / 3K / 4K,按模型支持)或 宽x高 像素写法(如 2048x2048);Seedream 5.0 Pro 另支持 adaptive。宽高均不超过 65536。全局约束
- 参考图数量 ≤ 14。
- 组图时「参考图数量 + 生成图数量 ≤ 15」;
auto未指定max_images时按上限预留。 - 未列出的字段会原样透传给上游,是否接受由上游决定。
与 OpenAI 图片协议的区别
本入口是官方 Seedream 协议,不是 OpenAI Images 协议。以下参数会被直接拒绝(HTTP 400):| 不接受的参数 | 替代方式 |
|---|---|
n | sequential_image_generation_options.max_images |
images | 官方字段是 image(单张字符串或数组均可) |
quality(如 fast) | optimize_prompt_options.mode: "fast" |
style / user / moderation / mask / input_fidelity / partial_images / output_compression | 官方协议无对应字段 |
示例
文生图(最小请求)
curl -X POST "https://api.shengmoai.com/seedream/api/v3/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "一只戴眼镜的橘猫在敲键盘写代码,赛博朋克风格"
}'
参考图生成
单张参考图直接传字符串,多张传数组:curl -X POST "https://api.shengmoai.com/seedream/api/v3/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"prompt": "融合两张参考图中的建筑风格,生成一张新城市街景",
"image": [
"https://example.com/ref-a.png",
"https://example.com/ref-b.png"
],
"size": "2K"
}'
组图(一次生成多张)
curl -X POST "https://api.shengmoai.com/seedream/api/v3/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "四季的城市街景,一套四张",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 4 }
}'
流式返回
curl -N -X POST "https://api.shengmoai.com/seedream/api/v3/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "四季的城市街景,一套四张",
"stream": true,
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 4 }
}'
响应
同步响应
{
"model": "doubao-seedream-4-0-250828",
"created": 1787309367,
"data": [
{
"url": "https://example.com/generated-1.png",
"size": "2048x2048"
}
],
"usage": {
"generated_images": 1,
"output_tokens": 16384,
"total_tokens": 16384
}
}
| 字段 | 说明 |
|---|---|
data[].url / data[].b64_json | 按 response_format 返回;url 有时效,请及时下载 |
data[].size | 实际尺寸,如 2048x2048 |
usage.generated_images | 成功生成的图片张数(计费依据) |
usage.total_tokens | 本次用量 |
response_format: "b64_json" 时 data 体积较大(单图可达数 MB),注意客户端接收上限。
流式响应
Content-Type: text/event-stream,事件类型与官方一致:
event: image_generation.partial_succeeded 每张图成功后推送一条(含 url/b64_json、size)
event: image_generation.partial_failed 单张失败推送一条(含 error),不影响其他图
event: image_generation.completed 收尾汇总事件(每请求一条,含 usage)
data: [DONE]
- 逐图事件可直接消费,拿到
partial_succeeded即可开始下载该图。 - 最终计费以
completed事件的usage为准。 - 部分渠道不支持流式:请求
stream: true时仍可能收到application/json普通响应,客户端请按Content-Type判断,两种都要兼容。
错误处理
本地参数校验失败返回 HTTP 400,不会产生费用:{
"error": {
"code": "InvalidParameter",
"message": "n is not a Seedream parameter; use sequential_image_generation_options.max_images to control the image count"
}
}
- 携带
n/images/ OpenAI 专有参数; max_images超出 1–15、非整数,或大于 1 却未开auto;- 参考图超过 14 张,或参考图 + 生成图超过 15;
image与images混用、数组含空字符串;prompt为空、Content-Type非 JSON、JSON 解析失败。
{"error": {"code": ..., "message": ...}}),HTTP 状态码保留。参数不被该模型支持(如对 5.0 Pro 开流式)时由此路径报错。令牌无效、额度不足返回 401 / 403 / 429,与其他接口一致。
相关页面
OpenAI 兼容图片接口
/v1/images/generations,兼容 OpenAI Images 协议
Qwen 图片生成
DashScope 官方协议的 Qwen-Image 入口
