外观
Seedream 图像生成与编辑
适用于模型 ID 含 seedream 的模型。本文以 seedream-v5-pro-n 为例,调用时保持大小写与后缀一致。
该模型属于图片生成模型,supported_endpoint_types 为 image-generation;不要通过 /v1/videos 调用,也不要传视频接口的 content、input_reference 或 asset:// 素材引用。
接口、异步任务、成功响应与错误码等公共说明,见图像生成与编辑总览。
生成
POST /v1/images/generations,JSON 请求体。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID,例如 seedream-v5-pro-n |
prompt | string | 是 | 图片描述 |
n | integer | 否 | 生成数量,1–128,默认 1 |
image | string | string[] | 否 | 单张或多张参考图 URL,也可传 data:image/...;base64,...;与 images 合计最多 10 张 |
images | string[] | 否 | 参考图 URL 数组;与 image 二选一,不要把同一张图同时放进两个字段 |
size | string | 否 | auto(自动)、1K、1.5K、2K,或 WIDTHxHEIGHT 像素尺寸 |
aspect_ratio | string | 否 | 1:1、16:9、9:16、4:3、3:4、21:9 |
background | string | 否 | opaque 或 transparent |
output_format | string | 否 | png 或 jpeg |
watermark | boolean | 否 | 是否添加水印 |
response_format | string | 否 | url 或 b64_json |
可选字段
size、aspect_ratio 可以按需传入,也可以同时传入;省略时使用模型默认值。不要直接套用 GPT 图像模型的参数枚举。
bash
curl "https://YOUR_API_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-v5-pro-n",
"prompt": "白色背景的商品摄影,柔和布光",
"n": 1,
"aspect_ratio": "16:9",
"response_format": "url"
}'异步调用
生成耗时较长时,在请求头加 Prefer: respond-async,再用 GET /v1/images/generations/{task_id} 轮询。完整流程见总览的异步模式。是否进入异步模式以响应头 Preference-Applied: respond-async 或响应体中的任务 ID 为准;未生效时按同步响应处理。
参考图
参考图使用可公开访问的 URL,或 data: 内联数据。单张使用 image:
json
{
"model": "seedream-v5-pro-n",
"prompt": "保持参考图人物和服装不变,改为电影感夜景街头肖像",
"image": "https://media.example.com/person.png",
"aspect_ratio": "3:4",
"response_format": "url"
}多张使用 images:
json
{
"model": "seedream-v5-pro-n",
"prompt": "参考第一张的人物、第二张的服装和第三张的光线,生成一张时尚杂志封面",
"images": [
"https://media.example.com/person.png",
"https://media.example.com/outfit.png",
"https://media.example.com/lighting.png"
],
"aspect_ratio": "3:4",
"response_format": "url"
}image 与 images 选择一种使用;同一张图不要同时放进两个字段。参考图请使用这两个字段,不要使用视频接口的 input_reference。
参考图计费
该模型的参考图前 5 张免费,第 6 张起按实际输入张数计入费用;生成图按输出档位和数量计费。
编辑
POST /v1/images/edits,必须提供参考图。支持 JSON 与 multipart 两种方式。
JSON 方式把参考图放在 image(单张)或 images(多张):
bash
curl "https://YOUR_API_BASE_URL/v1/images/edits" \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-v5-pro-n",
"prompt": "保持主体不变,把背景换成浅灰色",
"image": "https://media.example.com/reference.jpg",
"n": 1
}'也可以使用 multipart 上传本地文件:
bash
curl "https://YOUR_API_BASE_URL/v1/images/edits" \
-H "Authorization: Bearer sk-xxxxxxxx" \
-F "model=seedream-v5-pro-n" \
-F "prompt=保持主体不变,把背景换成浅灰色" \
-F "image=@reference.png"