Seedream(豆包)系列
字节跳动的豆包图像模型,共三款,通过 OpenAI 兼容接口 /v1/images/generations 调用,文生图与改图均使用该端点。
模型选择
- 支持 1K 尺寸
- 不支持组图与 4k 预设
- 支持组图与 4K
- 最低 2K
- 支持组图与 n 多张
- 最低 2K
volcengine/doubao-seedream-5.0-pro旗舰,支持 1K实时价格请参阅模型页 。
文生图
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1", timeout=600)
resp = client.images.generate(
model="volcengine/doubao-seedream-5.0-pro",
prompt="白色桌面上的一个红苹果",
size="2560x1440",
)
with open("output.jpg", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))输出格式固定为 JPEG,保存时请使用 .jpg 扩展名。默认返回 base64;传入 "response_format": "url" 可改为返回图片链接。
尺寸(size)
1k 与 1024×1024 均会被拒绝。size 支持两种写法:
- 分辨率档位
1k、2k、4k(不区分大小写):仅指定分辨率,比例由模型根据提示词决定。实测 4.5 传入2k时,输出既有 2048×2048,也有 1664×2496。 - 精确宽高
宽x高:比例固定,须满足下表的像素范围。
「—」表示本次未实测,请以火山方舟官方文档 为准。
常用的合法宽高(满足 4.5 和 5.0 Lite 的最低像素):
改图与多图参考
image 字段,而非 input_images;不支持 /v1/images/edits。Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.io/v1", timeout=600)
with open("apple.jpg", "rb") as f:
ref = "data:image/jpeg;base64," + base64.b64encode(f.read()).decode()
resp = client.images.generate(
model="volcengine/doubao-seedream-5.0-pro",
prompt="把苹果改成紫色,其他保持不变",
size="2k",
extra_body={"image": [ref]},
)
with open("apple_purple.jpg", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))image为数组,每项为图片 URL 或以data:image/...;base64,开头的字符串。多张参考图依次放入数组,并在提示词中说明每张图片的作用。input_images为 Qwen-Image 专用字段,Seedream 不支持。- Seedream 不支持
/v1/images/edits,改图请使用本节的image字段。
组图与多张
组图示例:
{
"model": "volcengine/doubao-seedream-5.0-lite",
"prompt": "生成 3 张独立的图:同一只狐狸分别在春天、夏天、秋天",
"size": "2k",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 }
}auto表示由模型决定生成张数,max_images仅为上限。实测相同请求下,4.5 将三格漫画合成在一张图中,仅返回 1 张。如需固定张数,请在提示词中明确写出「生成 N 张独立的图片」。- 每张图片单独计费,
usage.output_tokens为全部图片的合计。
水印
实测通过 OfoxAI 调用时默认不带水印,无需额外传参。
耗时
实测 2K 约 12 至 40 秒,3 张组图约 76 秒。客户端超时建议设置为 300 秒以上。
常见报错
报错原文末尾的 Request id: 0217… 为上游请求号,联系技术支持时请与响应中的 request_id 一并提供。
报错原文
The parameter `size` specified in the request is not valid: image size must be at least 3686400 pixels.
The parameter `size` specified in the request are not valid: image area must be at least 921600 pixels.
The parameter `size` specified in the request is not valid: image size must be at most 16777216 pixels.
The parameter `size` specified in the request is not valid: the specified size is not supported for model doubao-seedream-4-5.
The parameter `size` specified in the request are not valid: must be 'WIDTHxHEIGHT' or a supported size preset.
The parameter `size` specified in the request is not valid: size must be one of 'WIDTHxHEIGHT', '1k', '2k', or '4k'.
The parameter `sequential_image_generation` specified in the request are not valid: the parameter `sequential_image_generation` is not supported by the current model.
The parameter `output_format` specified in the request is not valid: the parameter `output_format` is not supported by the current model.官方文档
官方文档描述的是直连火山方舟时的行为;通过 OfoxAI 调用时,以本页实测结论为准。
常见问题
Seedream 报错 image size must be at least 3686400 pixels 怎么办?
Seedream 4.5 和 5.0 Lite 的最低尺寸是 2K,即 3,686,400 像素,1024x1024 和 1k 均不满足要求。改为 2k,或 2048x2048、2560x1440、1440x2560 等宽高。需要较小尺寸时请使用 5.0 Pro,它最低 921,600 像素(1280x720),也支持 1k。
Seedream 怎么改图?用 input_images 没有效果?
Seedream 的参考图字段是 image(数组,每项是图片 URL 或 data:image 开头的 base64),不是 input_images,input_images 是 Qwen-Image 的字段。另外 Seedream 不支持 /v1/images/edits,改图同样使用 /v1/images/generations。
Seedream 组图怎么一次生成多张?
传 sequential_image_generation: "auto" 和 sequential_image_generation_options.max_images。auto 表示由模型决定张数,max_images 是上限,在提示词中写明「生成 N 张独立的图」更稳定。5.0 Lite 和 4.5 支持,5.0 Pro 不支持。
Seedream 5.0 Pro 传 n 报 sequential_image_generation is not supported?
5.0 Pro 不支持一次生成多张,n 和组图参数都会返回此报错。删除 n,如需多张,请并发发起多次请求。
Seedream 生成的图片有水印吗?
通过 OfoxAI 调用,实测默认不带水印,无需额外传参。
Seedream 能输出 PNG 吗?
不能,输出固定为 JPEG。传入 output_format 会返回 400,删除该参数即可。
Seedream 的 size 传 2k 为什么比例不固定?
1k、2k、4k 只指定分辨率,比例由模型根据提示词决定。需要固定比例请传精确宽高,如 2560x1440。