跳到正文

Seedream 生成图像

POST/v1/images/generations

使用 Seedream 系列文生图,或通过 image 传入参考图生成,结果在同一次请求中返回。

模型与限制

模型规则分组可用接口n参考图prompt 上限(字符)
seedream-5.5Seedream 5.5 系列/v1/images/generations/v1/images/tasks10–10generations 的 image 字段10,000
seedream-5.5-nsfwSeedream 5.5 系列/v1/images/generations/v1/images/tasks10–10generations 的 image 字段10,000
seedream-5.0-proSeedream 5.0 Pro 系列/v1/images/generations/v1/images/tasks10–10generations 的 image 字段10,000
seedream-5.0-pro-nsfwSeedream 5.0 Pro 系列/v1/images/generations/v1/images/tasks10–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:1 1024x1024 · 4:3 1152x864 · 3:4 864x1152 · 16:9 1424x800 · 9:16 800x1424 · 3:2 1248x832 · 2:3 832x1248 · 21:9 1568x672
    • 1.5K1:1 1536x1536 · 4:3 1792x1344 · 3:4 1344x1792 · 16:9 2048x1152 · 9:16 1152x2048 · 3:2 1872x1248 · 2:3 1248x1872 · 21:9 2352x1008
    • 2K1:1 2048x2048 · 4:3 2368x1776 · 3:4 1776x2368 · 16:9 2816x1584 · 9:16 1584x2816 · 3:2 2496x1664 · 2:3 1664x2496 · 21:9 3136x1344
  • 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可选默认值 true

    true 在图片上添加“AI 生成”水印,false 不添加。

返回值

HTTP 200,返回图片列表。

  • createdinteger可选

    生成时间,Unix 秒。

  • dataobject[]可选

    生成的图片,每项一张。

    显示子字段(3)
    • urlstring可选

      图片下载地址。请直接使用返回的完整地址并尽快保存;下载时不要携带 API Key。

    • b64_jsonstring可选

      Base64 编码的图片数据;可能以此代替 url 返回,解码后保存。

    • width / height / sizeinteger / string可选

      图片尺寸,可能分别返回宽高或以 宽x高 返回,也可能不返回。

错误

错误返回 {"error": {"message": "...", "type": "...", "code": "..."}}。

HTTPcode原因与处理
400—参数无效,例如缺少 model、n 超过 128 或 size 使用了 ×;详见 error.message。
400asset_reference_not_foundasset:// 素材不存在或不属于你。
401—API Key 无效、过期或已禁用。
403insufficient_user_quota余额或 API Key 额度不足。
403—API Key 不允许此模型,或 IP 受限。
429—请求过快,稍后重试。
503model_not_found该模型当前没有可用渠道,或调用了 Seedream 不支持的接口(如 edits)。
524—网关等待生成超时(HTML 页面)。图片可能仍已生成并计费,先查看使用日志,再决定是否重试;长时间生成建议改用异步图片任务。
按 2K 档位文生图
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"
    }
  ]
}
参考图生成 2K 竖版 PNG
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"
    }
  ]
}
API 参考概述
鉴权、素材地址、幂等与错误格式。
接入文档
从准备密钥到下载结果的完整流程。
最后更新