跳转到主要内容

概览

这些接口面向已经使用火山风格 Seedance 任务结构的团队。它们保留任务式请求和响应结构,同时使用 TokenLab 的鉴权、计费、模型可用性和任务轮询。 另见 Seedance 2.0 视频模型视频生成

鉴权与入口

  • 使用 Authorization: Bearer <TOKENLAB_API_KEY>
  • 当前版本不接受火山 AK/SK 签名。只带 AK/SK 签名而没有 TokenLab Bearer 的请求会返回火山风格鉴权错误。
  • Version 可省略;如传入,必须为 2024-01-01
方式请求
REST 创建POST /api/v3/contents/generations/tasks
Action 创建POST /api/v3?Action=CreateContentsGenerationsTasks&Version=2024-01-01

内容规则

  • type: "text" 表示提示词文本。
  • type: "image_url" 不传 role 或传 role: "first_frame" 时按首帧处理。
  • role: "last_frame" 必须和首帧一起使用。
  • role: "reference_image"reference_videoreference_audio 表示参考素材。
  • 同一个请求里不要混用首尾帧输入和参考素材。

参数说明

  • ratio 支持 16:94:31:13:49:1621:9adaptive
  • duration 表示秒数,也支持模型允许的自动时长值。
  • resolution 可传 480p720p1080p4k,以前提是所选 Seedance 模型支持。
  • generate_audio 默认是 true;需要静音视频时传 false
  • watermarkreturn_last_frameseedpriorityexecution_expires_aftersafety_identifier 在符合所选模型规则时可用。
  • callback_url 暂不支持;请轮询任务状态。

图片准备

content[] 中包含图片 URL 时,TokenLab 会在所选 Seedance 模型需要素材引用时把它们准备为可复用素材。如果 60 秒内仍未准备完成,创建请求会返回可重试的素材准备中错误,而不是提交一个不完整的视频任务。

创建响应

{
  "id": "cgt-0123456789abcdef0123456789abcdef"
}
创建响应只包含兼容任务 ID。保存这个 ID,并调用查询任务接口轮询结果。

示例

REST 创建

curl https://api.tokenlab.sh/api/v3/contents/generations/tasks \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-0-260128",
    "content": [
      {"type": "text", "text": "A cinematic forest at sunset"},
      {"type": "image_url", "role": "reference_image", "image_url": {"url": "https://example.com/ref.png"}}
    ],
    "ratio": "16:9",
    "duration": 5,
    "resolution": "720p",
    "generate_audio": true
  }'

Action 创建

curl "https://api.tokenlab.sh/api/v3?Action=CreateContentsGenerationsTasks&Version=2024-01-01" \
  -H "Authorization: Bearer $TOKENLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-0-260128",
    "content": [{"type": "text", "text": "A clean product reveal video"}],
    "ratio": "16:9",
    "duration": 5,
    "resolution": "720p"
  }'

下一步

使用返回的 cgt-... ID 调用 查询任务(火山兼容),直到任务进入终态。