开发者 API · V1

Seedream 5.5 API

通过统一 REST 接口调用 Seedream 5.5、Seedream 5.5 Layers 与 Seedream 5 Pro,实现高质量文生图、图生图编辑、透明背景生成与图层拆解。与网页工作台共享同一套积分账本和生成历史。

  • Seedream 5.5 & 5 Pro
  • 透明 PNG 与图层拆解
  • 最多 10 张参考图
  • HMAC 签名 Webhook
  • 积分与历史互通

01

单一入口,覆盖三款 Seedream 模型

调用 POST /api/v1/seedream/generations,通过 model 字段无缝切换 seedream-5-5(文生图与多图编辑)、seedream-5-5-layers(图层拆解)与 seedream-5-pro。

02

共享积分账本与生成历史

每次 Seedream API 调用都直接从现有 FIFO 积分余额扣费,所有任务自动同步至个人中心的「历史记录」与「积分明细」。

03

签名 Webhook + 轮询查询

传入公网 HTTPS webhook_url 和可选 webhook_secret 即可接收 HMAC-SHA256 签名回调,也可随时轮询 GET /api/v1/seedream/generations/{id}。

04

与网页端同价,失败自动退费

与网页工作台计费完全一致,且不额外限制并发数与 RPM。任务失败、超时或拆层未用满名额时,系统自动退回对应积分。

鉴权与基础地址

使用 Bearer API 密钥调用所有 Seedream API 接口

在「个人中心 → API 密钥」创建并管理 sk- 密钥。所有请求均走 HTTPS,且需使用付费账号(已开通有效订阅或购买过积分包)。

基础地址 (Base URL)

https://seedream5-5.net/api/v1

鉴权请求头 (Authorization)

Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

幂等防重请求头(可选)

Idempotency-Key: req_20261127_001

在 POST /api/v1/seedream/generations 中携带 Idempotency-Key,网络超时重试将直接返回原任务而不会重复扣费。

调用 API 生成任务需要付费账号(有效订阅或已购积分包)。免费账号可以创建密钥和查询余额,升级后即可提交生成任务。

快速开始

发起你的第一次 Seedream 5.5 API 图像生成

在下方切换模型模式和编程语言。图生图编辑与图层拆解支持直接传入公网 HTTPS 图片 URL,无需额外上传步骤。

1. 创建生成任务
curl -X POST "https://seedream5-5.net/api/v1/seedream/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: req_20261127_001" \
  -d '{
  "model": "seedream-5-5",
  "prompt": "Minimalist matte-black ceramic pour-over coffee dripper centered on a clean studio backdrop, crisp editorial lighting.",
  "aspect_ratio": "1:1",
  "resolution": "1.5K",
  "output_format": "png",
  "background": "transparent",
  "webhook_url": "https://your-app.example.com/webhooks/seedream",
  "webhook_secret": "whsec_replace_with_at_least_16_chars"
}'
2. 轮询结果与查询余额
# 1. Poll generation status (returns image_url, images[], and layers[])
curl -X GET "https://seedream5-5.net/api/v1/seedream/generations/TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"

# 2. Check remaining credit balance & Seedream pricing
curl -X GET "https://seedream5-5.net/api/v1/credits" \
  -H "Authorization: Bearer YOUR_API_KEY"

接口清单

REST API 接口列表

所有接口均位于 /api/v1 路径下,请求与响应统一使用 application/json。

方法路径说明
POST/api/v1/seedream/generations创建 Seedream 生成任务(支持 seedream-5-5、seedream-5-5-layers 与 seedream-5-pro),支持 Idempotency-Key 与 webhook_url。
GET/api/v1/seedream/generations/{id}查询单条任务状态、持久化公网 image_url、images[]、layers[] 图层元数据、实际结算积分与错误信息。
GET/api/v1/seedream/generations分页获取账号下 Seedream 生成记录(网页与 API 互通),支持 ?page=1&limit=20(最大 50)、?model= 及 ?status=success|failed|pending|processing。
GET/api/v1/credits查询当前剩余积分余额、付费权限状态以及三款 Seedream 模型的完整计费标准。

请求参数规范

POST /api/v1/seedream/generations 参数说明

本接口严格仅开放 Seedream 系列模型。所有外部公网 HTTP(S) 图片 URL 均会经过基础安全校验后直接用于生成。

通用参数(所有 Seedream 模型)

参数名类型是否必填说明
modelstring必填可选 "seedream-5-5"、"seedream-5-5-layers" 或 "seedream-5-pro"。传入非 Seedream 模型将返回 400 invalid_model。
promptstring按模型决定seedream-5-5(5–5,000 字符)与 seedream-5-pro(3–5,000 字符)必填;seedream-5-5-layers 可选(0–2,000 字符)。
resolutionstring可选seedream-5-5:"1K"、"1.5K"(默认)、"2K";seedream-5-5-layers:"1K"、"1.5K"(默认)、"2K"、"auto";seedream-5-pro:"1K"(默认)、"2K"。别名:size。
output_formatstring可选输出图片格式:"png"(默认)或 "jpeg"。
webhook_urlstring (HTTPS)可选公网 HTTPS 回调地址,任务到达 success、failed 或 canceled 终态时自动发送 POST 通知。
webhook_secretstring可选16–256 位密钥,用于生成 X-Seedream-Signature(HMAC-SHA256)回调签名。需与 webhook_url 同时传入。

Seedream 5.5 与 Seedream 5 Pro(文生图 / 图生图)

参数名类型是否必填说明
aspect_ratiostring可选支持 "1:1"、"4:3"、"3:4"、"16:9"、"9:16"、"2:3"、"3:2"、"21:9"。seedream-5-5 图生图额外支持 "auto"(默认 "auto");seedream-5-pro 默认 "1:1"。
image_urlsstring[]可选最多 10 张公网参考图 URL(JPG、PNG、WebP),传入即自动进入图生图编辑模式;留空则为文生图。别名:images、image_input。
backgroundstring可选仅 seedream-5-5 支持:"auto"(默认)、"transparent"(透明背景,必须搭配 output_format: "png")或 "opaque"。

Seedream 5.5 Layers(seedream-5-5-layers 图层拆解)

参数名类型是否必填说明
image_urlstring (URL)必填单张待拆解的公网 HTTP(S) 图片 URL(推荐使用 PNG 或 JPEG)。别名:image、image_urls[0]。
max_imagesinteger可选最大拆解图层数量,范围 2–100(默认 2)。创建时按上限预扣,完成后按实际返回图层数自动退还多余积分。
text_recognitionboolean可选设为 true 时识别画面中的文字并拆分为独立透明图层。默认 false。

响应对象结构

任务状态机与图层返回结构

任务生命周期为 pending → processing → success(或 failed / canceled)。完成后,image_url 与 images[] 返回持久化公网图片地址,seedream-5-5-layers 同时返回包含层级与坐标信息的 layers[] 数组。

201 Created — 已入队任务
{
  "id": "8f3b2c1a-4d5e-4f6a-9b7c-1234567890ab",
  "object": "seedream.generation",
  "model": "seedream-5-5",
  "mode": "text-to-image",
  "status": "pending",
  "prompt": "Minimalist matte-black ceramic pour-over coffee dripper centered on a clean studio backdrop...",
  "aspect_ratio": "1:1",
  "resolution": "1.5K",
  "output_format": "png",
  "background": "transparent",
  "max_images": null,
  "text_recognition": null,
  "cost_credits": 6,
  "credits_refunded": false,
  "image_url": null,
  "images": [],
  "layers": null,
  "error": null,
  "webhook_url": "https://your-app.example.com/webhooks/seedream",
  "created_at": "2026-11-27T00:00:00.000Z",
  "updated_at": "2026-11-27T00:00:01.000Z"
}
200 OK — 已完成图层拆解
{
  "id": "4c9a1e2b-7f3d-4a5b-8c1e-abcdef123456",
  "object": "seedream.generation",
  "model": "seedream-5-5-layers",
  "mode": "layer-decomposition",
  "status": "success",
  "prompt": "Separate headline typography, foreground subject, and studio backdrop.",
  "aspect_ratio": "auto",
  "resolution": "1.5K",
  "output_format": "png",
  "background": null,
  "max_images": 6,
  "text_recognition": true,
  "cost_credits": 19,
  "credits_refunded": false,
  "image_url": "https://cdn.example.com/seedream/layers/task/0.png",
  "images": [
    "https://cdn.example.com/seedream/layers/task/0.png",
    "https://cdn.example.com/seedream/layers/task/1.png",
    "https://cdn.example.com/seedream/layers/task/2.png"
  ],
  "layers": [
    {
      "index": 0,
      "url": "https://cdn.example.com/seedream/layers/task/0.png",
      "z_index": 0,
      "name": "background",
      "description": "Studio backdrop",
      "size": "1536x1536",
      "bounding_box": {
        "absolute": [0, 0, 1536, 1536],
        "normalized": [0, 0, 1, 1]
      }
    }
  ],
  "error": null,
  "webhook_url": "https://your-app.example.com/webhooks/seedream",
  "created_at": "2026-11-27T00:00:00.000Z",
  "updated_at": "2026-11-27T00:00:24.000Z"
}

WEBHOOK 回调

异步接收终态回调通知

创建任务时传入 webhook_url 即可免去高频轮询。任务进入终态(success、failed 或 canceled)后,系统将立即向你的服务端发送 HTTPS POST 回调。

回调请求头说明

X-Seedream-Event
事件类型:generation.completed、generation.failed 或 generation.canceled。
X-Seedream-Delivery
本次回调投递序列的唯一 UUID。
X-Seedream-Timestamp
生成回调负载时的 Unix 秒级时间戳。
X-Seedream-Signature
配置 webhook_secret 后携带。格式为 sha256=hex(HMAC_SHA256(secret, "{timestamp}.{rawBody}"))。
  • 仅支持公网 HTTPS 地址;出于 SSRF 安全防护,自动拦截 localhost、内网/私网 IP 与 HTTP 重定向。
  • 请在 10 秒内返回任意 2xx HTTP 状态码以确认接收。
  • 遇到网络异常、408、429 或 5xx 响应时,系统自动重试最多 3 次。
Webhook 负载示例
{
  "event": "generation.completed",
  "timestamp": 1764201618,
  "data": {
    "id": "8f3b2c1a-4d5e-4f6a-9b7c-1234567890ab",
    "object": "seedream.generation",
    "model": "seedream-5-5",
    "mode": "text-to-image",
    "status": "success",
    "aspect_ratio": "1:1",
    "resolution": "1.5K",
    "output_format": "png",
    "background": "transparent",
    "cost_credits": 6,
    "credits_refunded": false,
    "image_url": "https://cdn.example.com/seedream/image/task-0.png",
    "images": ["https://cdn.example.com/seedream/image/task-0.png"],
    "layers": null,
    "error": null,
    "created_at": "2026-11-27T00:00:00.000Z",
    "updated_at": "2026-11-27T00:00:18.000Z"
  }
}
验证 X-Seedream-Signature 签名
import crypto from "node:crypto";

export function verifySeedreamSignature({ rawBody, timestamp, signature, secret }) {
  const expected =
    "sha256=" +
    crypto
      .createHmac("sha256", secret)
      .update(`${timestamp}.${rawBody}`)
      .digest("hex");

  const a = Buffer.from(signature || "", "utf8");
  const b = Buffer.from(expected, "utf8");
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}

积分计费说明

透明计费 — 与网页端 100% 一致

所有 Seedream API 请求均沿用网页工作台的真实计费公式,直接从同一账号积分余额扣除。

低至 6 积分 / 张
模型分辨率基础积分参考图与图层计费公式
seedream-5-51K / 1.5K6 积分文生图 6 积分;图生图按 6 + floor(参考图数 × 1.5) 计费(1–10 张)。
seedream-5-52K12 积分文生图 12 积分;图生图按 12 + floor(参考图数 × 1.5) 计费(1–10 张)。
seedream-5-5-layers1K / 1.5K (2K / auto)6(或 12)/ 层提交时预扣 max_images × 单层积分 + 1;完成后按实际图层数结算并自动退还多余预扣积分。
seedream-5-pro1K / 2K7 / 14 积分首张参考图免费;第 2–10 张参考图每张加收 1 积分。
  • 无任何 API 加价——所有模型、分辨率、参考图附加费与图层多退少补逻辑均与网页端完全一致。
  • 失败自动全额退费:任务失败或超过 30 分钟超时后,预扣积分自动原路退回至对应 FIFO 积分批次。
  • v1 版本不额外限制 API 并发数与 RPM,按积分余额正常消费。
查看积分包与套餐

错误处理

HTTP 状态码与错误码

所有错误响应均返回统一的 JSON 结构:{"error": {"code": "...", "message": "..."}}。

HTTP错误码含义与排查建议
400invalid_model / invalid_parameters / invalid_webhook_url请确认 model 属于 Seedream 系列、提示词长度与分辨率有效、透明背景已选 PNG,且图片/回调 URL 为公网地址。
401unauthorized缺少、格式错误或已失效的 Bearer API 密钥。
402insufficient_credits账号剩余积分不足以支付本次模型、分辨率及输入图数量所需费用,请前往套餐页充值。
403paid_account_required调用 API 需具备有效付费权限(订阅或积分包购买记录)。
404not_found指定的 Seedream 任务 ID 不存在、非 Seedream 任务或不属于当前账号。
409idempotency_conflict相同的 Idempotency-Key 被复用于不同的模型或生成模式。
502upstream_error任务提交失败,系统已自动全额退回预扣积分。

常见问题

Seedream 5.5 API 常见问题

Seedream 5.5 API 开放了哪些模型?

API 严格限定开放 Seedream 系列模型:seedream-5-5(文生图/图生图)、seedream-5-5-layers(图层拆解)和 seedream-5-pro(文生图/图生图),无法通过此 API 调用站内其他非 Seedream 模型。

API 调用与网页工作台的积分和历史记录互通吗?

完全互通。API 请求直接从你现有的 FIFO 积分账本扣费,且每条通过 API 创建的记录都会同步展示在「个人中心 → 历史记录」中。

哪些账号可以调用 Seedream 5.5 API?

拥有有效付费权限(任意有效订阅或已购买积分包)的账号均可调用。你可以在「个人中心 → API 密钥」创建 sk- 密钥。

Seedream 5.5 Layers 实际拆出的图层数少于 max_images 时如何计费?

任务创建时按 max_images 预扣积分(再加 1 积分输入费)。任务完成后系统会自动按实际返回的图层数量结算,并将未使用的预扣积分原路退回。

如何验证 Seedream Webhook 回调签名?

创建任务时同时传入 webhook_url 和 16–256 位 webhook_secret。收到回调后,使用密钥对 "{X-Seedream-Timestamp}.{rawBody}" 计算 HMAC-SHA256,并与请求头 X-Seedream-Signature 做恒定时间比对即可。

如何避免网络重试导致的重复扣费?

在 POST /api/v1/seedream/generations 请求头中传入唯一的 Idempotency-Key。使用相同 Key 重试会返回 HTTP 200 及原任务结果,不会重复创建任务或二次扣费。

准备好集成 Seedream 5.5 API 了吗?

几秒内创建你的 API 密钥,将 Seedream 5.5 文生图、多图编辑、透明资产与图层拆解能力无缝接入你的产品。