Seedream 生成图像
POST/v1/images/generations
使用 Seedream 系列文生图,或通过 image 传入参考图生成,结果在同一次请求中返回。
图片在本次 HTTP 请求中生成并返回,耗时可能较长,请把客户端超时设为 240 秒以上。超时、断连或 5xx 时图片仍可能已生成并计费,同步接口没有幂等保护,重复提交会再次扣费。需要安全重试时请改用“创建图像任务”(POST /v1/images/tasks)。
请只使用本页列出的取值:未列出的取值可能被拒绝、被忽略或产生非预期结果,且同步请求一旦被受理仍会计费。
模型与限制
| 模型 | 规则分组 | 可用接口 | n | 参考图 | prompt 上限(字符) |
|---|---|---|---|---|---|
seedream-5.5 | Seedream 5.5 系列 | /v1/images/generations/v1/images/tasks | 1 | 0–10generations 的 image 字段 | 10,000 |
seedream-5.5-nsfw | Seedream 5.5 系列 | /v1/images/generations/v1/images/tasks | 1 | 0–10generations 的 image 字段 | 10,000 |
seedream-5.0-pro | Seedream 5.0 Pro 系列 | /v1/images/generations/v1/images/tasks | 1 | 0–10generations 的 image 字段 | 10,000 |
seedream-5.0-pro-nsfw | Seedream 5.0 Pro 系列 | /v1/images/generations/v1/images/tasks | 1 | 0–10generations 的 image 字段 | 10,000 |
请求头
Authorizationstring必填Bearer <API_KEY>。Content-Typestring必填application/json。本站只支持 JSON 请求体。
请求体参数JSON
modelstring必填Seedream 系列的模型 ID,区分大小写。可用模型见下方;5.5 与 5.0 Pro 系列的部分参数不同,见各参数的“按模型分组”。
- Seedream 5.5 系列
seedream-5.5seedream-5.5-nsfw- Seedream 5.0 Pro 系列
seedream-5.0-proseedream-5.0-pro-nsfw
promptstring必填描述要生成的画面,不能为空,不超过 10,000 个字符;建议中文不超过 300 字,效果更稳定。使用分辨率档位(如
2K)时,请在提示词里写明目标画幅。imagestring | string[]可选参考图,可传单个地址或 1–10 个地址的数组;文生图时省略。Seedream 不使用
images字段。限制
- 公网可直接访问的
https://图片地址,或你素材库中的asset://<素材ID>(素材须属于当前 API Key 的所有者)。 - 支持 PNG、JPEG、WebP。地址不能依赖 Cookie、鉴权头、防盗链或很快过期的签名。
- 公网可直接访问的
ninteger可选默认值1只支持 1,可省略。
按“单张价格 × 张数”计费,提交时按
n预扣。sizestring可选默认值2K传分辨率档位
1K、1.5K或2K,画幅由提示词决定;或传下表中对应档位与画幅的固定宽高。不支持其他宽高。宽高之间用小写字母
x,不能用乘号×。支持的取值
1K1:11024x1024· 4:31152x864· 3:4864x1152· 16:91424x800· 9:16800x1424· 3:21248x832· 2:3832x1248· 21:91568x6721.5K1:11536x1536· 4:31792x1344· 3:41344x1792· 16:92048x1152· 9:161152x2048· 3:21872x1248· 2:31248x1872· 21:92352x10082K1:12048x2048· 4:32368x1776· 3:41776x2368· 16:92816x1584· 9:161584x2816· 3:22496x1664· 2:31664x2496· 21:93136x1344
backgroundstring可选背景类型。
按模型分组
- Seedream 5.5 系列
auto(默认)、opaque、transparent。透明输出需output_format: "png";可文生透明图,也可用普通参考图生成透明图。- Seedream 5.0 Pro 系列
opaque(默认)、transparent,不支持auto。transparent要求image恰好为一张自带透明通道的 PNG,并且output_format: "png"。
output_formatstring可选图片文件格式,只支持
png与jpeg。按模型分组
- Seedream 5.5 系列
- 默认
png。 - Seedream 5.0 Pro 系列
- 默认
jpeg。
watermarkboolean可选默认值truetrue在图片上添加“AI 生成”水印,false不添加。
返回值
HTTP 200,返回图片列表。
createdinteger可选生成时间,Unix 秒。
dataobject[]可选生成的图片,每项一张。
显示子字段(3)
urlstring可选图片下载地址。请直接使用返回的完整地址并尽快保存;下载时不要携带 API Key。
b64_jsonstring可选Base64 编码的图片数据;可能以此代替
url返回,解码后保存。width / height / sizeinteger / string可选图片尺寸,可能分别返回宽高或以
宽x高返回,也可能不返回。
错误
错误返回 {"error": {"message": "...", "type": "...", "code": "..."}}。
| HTTP | code | 原因与处理 |
|---|---|---|
| 400 | — | 参数无效,例如缺少 model、n 超过 128 或 size 使用了 ×;详见 error.message。 |
| 400 | asset_reference_not_found | asset:// 素材不存在或不属于你。 |
| 401 | — | API Key 无效、过期或已禁用。 |
| 403 | insufficient_user_quota | 余额或 API Key 额度不足。 |
| 403 | — | API Key 不允许此模型,或 IP 受限。 |
| 429 | — | 请求过快,稍后重试。 |
| 503 | model_not_found | 该模型当前没有可用渠道,或调用了 Seedream 不支持的接口(如 edits)。 |
| 524 | — | 网关等待生成超时(HTML 页面)。图片可能仍已生成并计费,先查看使用日志,再决定是否重试;长时间生成建议改用异步图片任务。 |
curl -X POST https://ling-light.com/v1/images/generations \
-H "Authorization: Bearer $LINGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-5.5",
"prompt": "16:9 横版,清晨薄雾中的湖边木屋,写实摄影风格",
"size": "2K",
"output_format": "png"
}'const response = await fetch('https://ling-light.com/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "seedream-5.5",
"prompt": "16:9 横版,清晨薄雾中的湖边木屋,写实摄影风格",
"size": "2K",
"output_format": "png"
}),
})
console.log(response.status, await response.json())import os
import requests
response = requests.post(
"https://ling-light.com/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
},
json={
"model": "seedream-5.5",
"prompt": "16:9 横版,清晨薄雾中的湖边木屋,写实摄影风格",
"size": "2K",
"output_format": "png",
},
timeout=60,
)
print(response.status_code, response.json()){
"created": 1795660800,
"data": [
{
"url": "https://media.example.com/images/example.png",
"size": "2816x1584"
}
]
}curl -X POST https://ling-light.com/v1/images/generations \
-H "Authorization: Bearer $LINGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-5.5",
"prompt": "保留参考图中的花瓶与花枝,生成竖版水彩插画,浅米色背景",
"image": [
"https://media.example.com/images/reference.png"
],
"size": "1584x2816",
"background": "opaque",
"output_format": "png",
"watermark": false
}'const response = await fetch('https://ling-light.com/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "seedream-5.5",
"prompt": "保留参考图中的花瓶与花枝,生成竖版水彩插画,浅米色背景",
"image": [
"https://media.example.com/images/reference.png"
],
"size": "1584x2816",
"background": "opaque",
"output_format": "png",
"watermark": false
}),
})
console.log(response.status, await response.json())import os
import requests
response = requests.post(
"https://ling-light.com/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
},
json={
"model": "seedream-5.5",
"prompt": "保留参考图中的花瓶与花枝,生成竖版水彩插画,浅米色背景",
"image": [
"https://media.example.com/images/reference.png",
],
"size": "1584x2816",
"background": "opaque",
"output_format": "png",
"watermark": False,
},
timeout=60,
)
print(response.status_code, response.json()){
"created": 1795660800,
"data": [
{
"url": "https://media.example.com/images/example.png",
"size": "1584x2816"
}
]
}