Seedream 5.5

使用 doubao-seedream-5.5 进行文生图、参考图编辑、最多十张图片融合、透明背景生成,以及带可选文字识别的图层拆分。普通生成返回一张图片;图层拆分返回底图和独立图层。

计价规则

每张输入图片均收费,包括首张。每张输出按实际返回尺寸分档,底图与每个图层分别计费。

计费项单张参考积分
每张输入图片1.95
输出图片 ≤2,610,000 像素5.07
输出图片 >2,610,000 像素8.97

请求参数

接口:POST /v1/images/generations。使用 Authorization: Bearer sk-your-api-key 鉴权。

字段类型必填说明
modelstring是doubao-seedream-5.5。
inputobject是下表中的生成参数。
callback_urlstring否接收完成或失败通知的地址。

Input 参数

参数类型说明
promptstring普通生成必填且不能为空;图层拆分可省略。
image_urlsstring[]公网 HTTP(S) URL。生成或编辑最多十张参考图,拆层必须恰好一张。每张输入均收费。
layer_decompositionboolean默认 false;设为 true 开启图层拆分。
layer_decomposition_options.max_imagesinteger仅拆层可用。底图加图层的最多张数,范围 2–100,默认 30。
layer_decomposition_options.text_recognitionboolean仅拆层可用。默认 false;识别规整文字及近似样式。
sizestring普通生成:1K、1.5K、2K(默认)或 宽x高。拆层:auto(默认)、1K、1.5K、2K。
output_formatstringpng(默认)或 jpeg。拆层时只控制底图格式,前景图层始终为 PNG。
backgroundstring仅普通生成可用:auto(默认)、transparent、opaque。透明背景必须使用 PNG。
optimize_prompt_options.modestring仅支持 standard。
watermarkboolean默认 false,不添加水印;显式设为 true 可添加 AI 生成水印。
safety_identifierstring可选终端用户标识,最多 64 个字符,建议使用用户标识的哈希值。

精确尺寸的总像素必须在 921,600–4,624,220 之间,宽高比在 1/16–16 之间。auto 只用于拆层。拆层不能传精确尺寸、background,也不能传零张或多张输入图片;普通生成不能传 layer_decomposition_options。transparent 与 jpeg 不能同时使用。透明背景支持无参考图生成,也不要求输入图片具有透明通道。

输入文件须可公开访问,每张不超过 30 MB。普通生成接受 JPEG、PNG、WebP、BMP、TIFF、GIF、HEIC、HEIF,宽高均大于 14 像素,总像素为 196–36,000,000。拆层仅接受 PNG 或 JPEG,总像素为 262,144–36,000,000。两种模式的输入宽高比均须在 1/16–16 之间。

使用 image_urls 传图,结果使用 URL。不支持原生 image、Base64 输入、response_format、stream、sequential_image_generation、sequential_image_generation_options 或 tools。不要另外传输出张数:普通生成一张,拆层由 max_images 控制上限。

图片生成、编辑与融合

以下请求使用默认 2K、PNG 进行文生图:

curl -X POST https://api.aivideoapi.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5.5",
    "input": {
      "prompt": "日出时分,一座安静的海边图书馆"
    }
  }'

编辑单图时,在 image_urls 传一张图片;多图融合时最多传十张,并在提示词中描述组合方式。以下示例将两张参考图融合为透明背景图片:

curl -X POST https://api.aivideoapi.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5.5",
    "input": {
      "prompt": "将第一张图片的产品与第二张图片的丝带组合,使用透明背景",
      "image_urls": ["https://example.com/product.png", "https://example.com/ribbon.png"],
      "background": "transparent",
      "output_format": "png",
      "size": "2K",
      "watermark": false
    }
  }'

图层拆分与文字识别

以下请求省略提示词与尺寸,默认最多 30 张输出,同时开启文字识别:

curl -X POST https://api.aivideoapi.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedream-5.5",
    "input": {
      "image_urls": ["https://example.com/poster.png"],
      "layer_decomposition": true,
      "layer_decomposition_options": {"text_recognition": true}
    }
  }'

可将 max_images 设为 2–100,控制底图与图层的总张数上限;这不是最终计费张数。较大的上限通常拆分更细。提示词要求的数量超过上限时,部分图层信息可能丢失。

异步任务与结果

接单后立即返回 taskId,在后台直接调用一次图片生成服务。通过现有任务查询或回调协议获取结果。

创建任务返回现有协议的任务 ID:

{"code":200,"msg":"success","data":{"taskId":"00000000-0000-4000-8000-000000000055"}}

使用同一任务 ID 查询结果:

curl https://api.aivideoapi.ai/v1/tasks/00000000-0000-4000-8000-000000000055 \
  -H "Authorization: Bearer sk-your-api-key"

任务状态为 pending、processing、completed、failed 或 cancelled。尚未提交上游的任务可以取消并退还预扣;提交后不再允许取消。待核对任务可能保持待处理或处理中。超时后继续查询原任务,避免再次提交。也可传 callback_url 接收通知,签名校验与重试规则见回调通知。

查询结果的顶层 settlement_status 表示计费进度:pending 为等待结果或结算,reconciliation_required 为待核对且保留预扣,settled 为已按实际结果结算,not_charged 为任务失败或取消后已退还预扣。待核对时继续查询原任务,核对完成后此字段会更新。

完成结果保留 output.urls,按 output.metadata.images 中的 output_index 与对应 URL 关联;即使 URL 重复也应保留每一项。图片信息包括实际 size、output_format、background,以及可选的图层 z_index、名称 name、描述 description、坐标 bounding_box 和 text_recognition。

以下拆层结果包含一张底图和一张文字图层。URL 均为占位示例。

{
  "id": "00000000-0000-4000-8000-000000000055",
  "status": "completed",
  "model": "doubao-seedream-5.5",
  "credits_consumed": 15.98,
  "settlement_status": "settled",
  "output": {
    "urls": ["https://example.com/base.png", "https://example.com/title.png"],
    "metadata": {
      "model": "doubao-seedream-5.5",
      "usage": {"input_images": 1, "generated_images": 2},
      "layer_decomposition": true,
      "requested_image_count": 30,
      "generated_images": 2,
      "settlement_status": "settled",
      "images": [
        {"output_index": 0, "size": "2048x2048", "output_format": "png", "background": "opaque", "z_index": 0},
        {
          "output_index": 1,
          "size": "1600x1000",
          "output_format": "png",
          "background": "transparent",
          "z_index": 1,
          "name": "标题",
          "description": "海报标题文字",
          "bounding_box": {"absolute": [224, 200, 1824, 1200], "normalized": [109, 98, 891, 586]},
          "text_recognition": {
            "text": "SUMMER",
            "lines": [{
              "bounding_box": {"absolute": [400, 400, 1648, 700], "normalized": [195, 195, 805, 342]},
              "runs": [{"text": "SUMMER", "style": {"similar_font_family": "Arial", "foreground_color": "#FFFFFF", "bold": true, "italic": false, "underline": false, "strikethrough": false, "shadow": false, "translucent": false}}]
            }]
          }
        }
      ]
    }
  }
}

底图的 z_index 为 0,不返回边界框。按 z_index 从小到大叠放图层。bounding_box.absolute 与 .normalized 均使用底图坐标系下的 [left, top, right, bottom],归一化坐标范围为 0–1000。输出图片尺寸与边界框尺寸可能不同。

OCR text 是图层完整文本,行间以 \n 分隔。lines[].runs[] 包含同一样式的文字片段及近似样式。非文字图层、手写体或艺术字可能不返回 text_recognition;字体无法识别时,similar_font_family 可以为 unknown。

默认直接返回生成结果的原始图片 URL;账户显式开启 R2 转存后,返回转存后的 URL。Playground 支持图层预览、下载、复制识别文字以及查看详细信息。请及时下载结果,原始图片 URL 通常有效约 24 小时。


常见错误码

请求失败时,API 返回 JSON 格式的错误响应:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

错误码一览

HTTP 状态码错误码类型说明
400invalid_requestinvalid_request_error缺少必填参数或参数无效
401invalid_api_keyauthentication_errorAPI Key 无效、已禁用或已删除
402insufficient_creditsbilling_error积分余额不足,请充值
403ip_not_allowedpermission_error请求 IP 不在 Key 的白名单中
404model_not_foundinvalid_request_error模型不存在或已停用
404task_not_foundinvalid_request_error任务 ID 不存在
429rate_limit_exceededrate_limit_error请求过于频繁,请降低频率
429spend_limit_exceededbilling_error达到 Key 的消费限额(每小时/每天/总量)
500internal_errorapi_error服务器内部错误
503upstream_errorupstream_error上游 AI 服务返回错误

常见场景

invalid_request (400)

缺少必填字段或参数格式错误时返回。

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。

invalid_api_key (401)

可能原因:

  • Key 不以 sk- 开头
  • Key 已被禁用或删除
  • 用户账户已被封禁

upstream_error (503)

上游 AI 服务返回错误,可能原因:

  • 输入内容包含敏感或违规信息
  • 上游服务暂时不可用
  • 请求参数不被上游支持

因上游错误导致任务失败时,预扣积分会自动退还。