Doubao Seedream API
字节跳动豆包 Seedream 系列,多档模型可选,支持文生图、图片编辑和多图融合。
认证
Authorization: Bearer YOUR_API_KEY模型与价格
| 模型 | model | 价格 | 说明 |
|---|---|---|---|
| Seedream 5.0 Pro | doubao-seedream-5-0-pro | $0.03 / $0.06 | 旗舰,1K/2K(分档计价) |
| Seedream 5.0 Flash | doubao-seedream-5-0-flash | $0.03/张 | 极速档,1K/2K 同价,支持透明背景编辑与图层拆分(按输出张数计费) |
| Seedream 5.0 Lite (Official) | doubao-seedream-5-0-260128 | $0.055/张 | 火山方舟官方通道,2K/4K |
| Seedream 4.5 | doubao-seedream-4-5-251128 | $0.05/张 | 2K/4K |
代码示例
# 5.0 Lite official channel: same endpoint for T2I and I2I.
# Provide image_url for image-to-image; omit it for text-to-image.
# size: "2K" (default) or "4K". aspect_ratio sets the shape (square when omitted).
# Step 1a: Text-to-image
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"prompt": "A cherry blossom tree by a tranquil river, impressionist painting style",
"size": "2K"
}'
# Step 1b: Image-to-image (same endpoint, just add image_url)
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-260128",
"prompt": "Change the season to winter with snow",
"image_url": "https://example.com/landscape.jpg",
"size": "4K"
}'
# Step 2: Poll status
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"图层拆分(仅 5.0 Flash)
同一个端点,多传 layer_decomposition: true 和一张 PNG/JPEG,返回 1 张底图加最多 16 个透明 PNG 图层,每层带 name、description、z_index 和 bounding_box,按输出张数每张 $0.03(建单按 17 张预扣,完成后按实际结算)。不传 prompt 就拆出全部主要元素,点名(「只拆文字」「把运动鞋和价签拆出来」)就只拆那几样。
# Layer decomposition (Seedream 5.0 Flash only): one PNG/JPEG in,
# a base image + up to 16 transparent PNG layers out, $0.03 per output image.
# Omit "prompt" to split every main element; name the parts ("Separate only the text.")
# for a selective split. The last sentence sets the language of layer names (default: Chinese).
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-5-0-flash",
"image_url": "https://example.com/poster.jpg",
"layer_decomposition": true,
"prompt": "Separate every main element onto its own layer. Write every layer name and description in English.",
"size": "2K"
}'
# Poll. resultUrls = base first, then layers in z_index order;
# resultJson.layers[i] = { z_index, name, description, bounding_box: { absolute, normalized }, url }
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"八个真实案例(海报、商品图、图标、按需抠图)可逐层查看:Seedream 5.0 Flash
请求参数
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | doubao-seedream-5-0-pro / doubao-seedream-5-0-flash / doubao-seedream-5-0-260128 / doubao-seedream-4-5-251128 |
| prompt | 是 | string | 图片描述或编辑指令;图层拆分模式下可省略(省略即自动拆全部主要元素) |
| image_url | 否 | string | 参考图:公网 URL 或 base64/data-URI 均可。5.0 Lite 传则走图生图、不传则走文生图(同一 endpoint) |
| image_urls | 否 | string[] | 多张参考图(仅 4.5):每项可为 URL 或 base64/data-URI |
| image_base64 | 否 | string | 单张参考图的 base64/data-URI(本地文件用,等价于 image_url 传 base64) |
| aspect_ratio | 否 | string | "1:1"、"4:3"、"3:4"、"16:9"、"9:16"、"3:2"、"2:3"、"5:4"、"4:5"、"21:9"(全系通用;不传出方图)。size 与它同时给时以 aspect_ratio 为准,size 只决定档位。 |
| size | 否 | string | 5.0 Pro:1K 或 2K(默认 2K,分档计价 1K $0.03 / 2K $0.06,无 4K);5.0 Flash:1K 或 2K(默认 2K,均为 $0.03,无 4K);5.0 Lite:2K(默认)或 4K |
| layer_decomposition | 否 | boolean | 仅 5.0 Flash:true 把一张图拆成 1 张底图加最多 16 个透明 PNG 图层。必须恰好传 1 张 PNG 或 JPEG 参考图;prompt 可省略(省略则自动拆出全部主要元素);size 只看 1K / 2K 档位,底图比例跟随原图;不能与 background "transparent" 同用。按输出张数计费,每张 $0.03(底图也算一张),建单时按上限 17 张预扣、完成后按实际张数结算。结果:resultUrls 依次是底图和各层;resultJson.layers[i] 给出 z_index(0 为底图,越大越靠上)、name、description、bounding_box(absolute 为像素,normalized 为 0–1000)与对应 url。图层名称与描述由模型生成,默认中文;在 prompt 末尾加一句「Write every layer name and description in English.」即返回英文。两个实测事实:底图不是原图,是抬走各层后补全的画面;每个图层 PNG 都比它的 bounding_box 大(每边约 2–4 倍,比例不变),合成时按 absolute 缩放定位。实测 25–74 秒。模型页有 8 个真实案例可逐层查看。 |
| background | 否 | string | 仅 5.0 Pro / Flash:"transparent" 编辑一张本身带透明通道的 PNG 并保留透明,输出 PNG。必须恰好传 1 张参考图;不能用文生图直接生成透明图;不能与 output_format "jpeg" 同用。 |
| resolution | 否 | string | 仅 4.5:1k/2k/3k/4k |
| callback_url | 否 | string | 任务完成后的回调 URL |
说明
- Seedream 5.0 最高支持 3K 分辨率
- Seedream 4.5 和 4.0 最高支持 4K 分辨率
- 通过 image_urls 数组实现多图融合
- ⚠ 参考图 URL 必须公网可直接访问且响应够快——上游(火山引擎,国内)会主动下载该 URL,海外/慢图床(如 Railway 免费层)常因跨境下载超时而失败。追求稳定请传 base64 / data-URI,或使用可达的 CDN。
相关:5.0 Pro 详细文档见 Seedream 5.0 Pro;模型页:Seedream 5.0 Lite · Seedream 5.0 Pro · Seedream 5.0 Flash(每个模型页都带 Playground 可直接试)
常见问题
Seedream 该选哪一档?
5.0 Pro 是旗舰(1K/2K,交互编辑);5.0 Lite 走官方通道,$0.055,2K/4K;4.5 是入门档,$0.05,最高 4K,可用 image_urls[] 多图融合。
为什么传参考图 URL 会下载超时失败?
上游(在国内)会主动下载你的 URL,海外/慢图床常跨境超时。改传 base64 / data-URI,或把图放到可快速访问的 CDN。