跳到主要内容

Seedance 素材库(Action 风格)

Action 风格统一入口,兼容火山引擎官方 SDK(Ark)的调用约定:所有操作走统一入口,Action / Version 通过 URL 查询参数指定,业务参数放 JSON 请求体。

1. 入口与认证​

POST /api/seedance/proxy/openapi?Action=<ACTION>&Version=<VERSION>
  • Base URL:网关域名:https://token.taiha.cn

  • 仅支持 POST:其他方法返回 405(入口层错误格式,见 第 8 节)

  • 认证:

    • Bearer 令牌:Authorization: Bearer sk-xxxxxxxx
    • 火山官方 SDK 签名(AK/SK,HMAC-SHA256):Authorization: HMAC-SHA256 Credential=...,并额外携带 X-Date、X-Content-Sha256 头,见左侧菜单【素材库鉴权】
  • 本文档示例统一以 Bearer 为例:Bearer 无需 X-Date / X-Content-Sha256;AK/SK 客户端仅需按鉴权文档替换认证头(路径与请求体完全不变),签名字段由签名代码自动生成

  • Version:网关不校验(任意值均可)。实际发往上游时统一改写为固定版本 2024-01-01,因此上游透传的响应(写操作、详情查询)ResponseMetadata.Version 固定为 2024-01-01;仅网关合成 ResponseMetadata 的场景(列表回退数据库、网关校验错误)回显客户端所传值,缺省 2024-01-01。建议客户端统一传 2024-01-01

  • 其他 URL 查询参数:网关宽松忽略(不透传上游、不报错)

  • 请求体:JSON 对象;空请求体按 {} 处理(交由各 Action 的必填校验报错),非 JSON 返回 400 invalid_json

Request 示例:

curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=CreateAssetGroup&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Name": "my-group", "Description": "第一个group"}'

2. Action 一览​

Action功能对应 REST 风格接口
CreateAssetGroup创建素材组POST /assets/groups
ListAssetGroups查询素材组列表GET /assets/groups
GetAssetGroup查询素材组详情—(REST 风格未提供)
UpdateAssetGroup修改素材组—(REST 风格未提供)
DeleteAssetGroup删除素材组—(REST 风格未提供)
CreateAsset创建素材(异步)POST /assets
ListAssets查询素材列表GET /assets
GetAsset查询素材详情GET /assets/{asset_id}
UpdateAsset修改素材PUT / PATCH /assets/{asset_id}
DeleteAsset删除素材DELETE /assets/{asset_id}

Action 缺失或不在上述白名单内:403 official_action_not_allowed(入口层错误格式)。

3. 响应格式​

所有成功响应为官方结构(ResponseMetadata + Result):

{
"ResponseMetadata": {
"RequestId": "20260928151023A1B2C3D4E5F6071",
"Action": "CreateAssetGroup",
"Version": "2024-01-01",
"Service": "ark",
"Region": "cn-beijing"
},
"Result": { "Id": "group-20260928151023-xxxxx" }
}
  • ResponseMetadata:写操作与详情查询原样透传上游;列表由网关过滤重组 Result,ResponseMetadata 优先透传上游,无上游响应可透传时由网关合成(RequestId 格式为 YYYYMMDDHHMMSS + 16 位大写十六进制)
  • RequestId 不入库:仅用于链路排查(网关日志)
  • 列表 Result 同时携带两套分页字段:Items / TotalCount / NextToken / PageNumber / PageSize,页码式与游标式客户端均可读取

4. 素材组 Action​

CreateAssetGroup​

Request Body(JSON):

字段类型必填说明
Namestring是组名,1~64 字符
Descriptionstring否组描述,最长 300 字符
GroupTypestring否仅支持 AIGC(缺省);真人素材组须经人脸认证获得,不能手动创建

请求体按校验后的字段重构发往上游(ProjectName 及鉴权类托管字段自动剔除)。

Request 示例:

curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=CreateAssetGroup&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Name": "my-group", "Description": "第一个group"}'

校验规则:同一用户下 Name + GroupType 唯一(上游不区分用户、不查重名,由网关兜底),重复创建返回 400。

Response 200(上游透传):

{
"ResponseMetadata": { "RequestId": "...", "Action": "CreateAssetGroup", "Version": "2024-01-01", "Service": "ark", "Region": "cn-beijing" },
"Result": { "Id": "group-20260928151023-xxxxx" }
}

建组成功后网关记录归属映射(供后续归属校验与列表回退使用),记录失败返回 500。

错误:

状态码CodeMessage
400MissingParameter.NameThe required parameter Name is missing.
400InvalidParameter.NameName must be at most 64 characters / an asset group with the same Name and GroupType already exists
400InvalidParameter.DescriptionDescription must be at most 300 characters
400InvalidParameter.GroupTypeOnly AIGC group type is supported
500InternalErrorfailed to check asset group / failed to record asset group
502UpstreamErrorSeedance upstream unavailable

ListAssetGroups​

Request Body(JSON,官方 Filter 结构):

字段类型必填说明
Filter.GroupTypestring否AIGC(缺省)/ LivenessFace
Filter.GroupIdsstring[]否组 ID 列表;缺省查本人该类型全部组;传入须均为本人组,否则 403
Filter.Namestring否组名精确匹配,最长 64 字符(以网关建组记录为准)
PageNumberint否页码,缺省 1;宽松兼容字符串数字
PageSizeint否每页数量,1~100,缺省 10
SortBystring否CreateTime(缺省)/ UpdateTime
SortOrderstring否Desc(缺省)/ Asc
NextToken / MaxResults—否游标风格分页,宽松兼容(规则同 REST 风格通用说明)

Request 示例:

curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=ListAssetGroups&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Filter":{"GroupType":"AIGC"},"PageNumber":1,"PageSize":20}'

Response 200:

{
"ResponseMetadata": { "RequestId": "...", "Action": "ListAssetGroups", "Version": "2024-01-01", "Service": "ark", "Region": "cn-beijing" },
"Result": {
"Items": [
{
"Id": "group-20260928151023-xxxxx",
"Name": "my-group",
"Description": "第一个group",
"GroupType": "AIGC",
"CreateTime": "2026-09-28T15:10:23+08:00",
"UpdateTime": "2026-09-28T15:10:23+08:00"
}
],
"TotalCount": 1,
"NextToken": "",
"PageNumber": 1,
"PageSize": 20
}
}

说明:

  • 分页宽松规则与 REST 风格一致:NextToken 优先于 PageNumber,PageSize 优先于 MaxResults,未传分页参数默认每页 10 条,NextToken 为空串/无效时回退 PageNumber,响应始终携带 Result.NextToken
  • 上游列表不区分用户,网关始终按本人素材组过滤;item 缺 Name 时以网关建组记录补齐
  • 上游查询失败或无数据时自动回退网关数据库元数据(此时 ResponseMetadata 由网关合成)
  • 本人无符合条件的素材组时直接返回空列表(不查上游)

错误:400(InvalidParameter.GroupType / .Name / .SortBy / .SortOrder / .PageSize)、403(Forbidden.GroupIds:GroupIds contain asset groups not belonging to you)、500、502

GetAssetGroup / UpdateAssetGroup / DeleteAssetGroup​

Request Body(JSON):

字段类型必填说明
Idstring是素材组 ID,须为本人素材组(普通 + 真人认证),否则 403
Namestring否UpdateAssetGroup:新组名,1~64 字符
Descriptionstring否UpdateAssetGroup:新描述,最长 300 字符

Request 示例(三个 Action 仅 Action 参数与请求体不同):

# GetAssetGroup:查详情
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=GetAssetGroup&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "group-20260928151023-xxxxx"}'

# UpdateAssetGroup:改名 / 改描述(至少填一项)
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=UpdateAssetGroup&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "group-20260928151023-xxxxx", "Name": "renamed-group", "Description": "新描述"}'

# DeleteAssetGroup:删除
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=DeleteAssetGroup&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "group-20260928151023-xxxxx"}'

说明:

  • Update 时 Name / Description 至少填一项(两者均缺省由上游报错);改名维持同用户 Name + GroupType 唯一(排除自身)
  • 请求体按白名单字段(Id / Name / Description)重构发往上游,其余字段剔除
  • 上游操作成功后网关同步归属记录(Update 改元数据 / Delete 删记录,尽力而为,同步失败仅记日志不影响响应)
  • 响应为上游透传(状态码与响应体)

错误:400(MissingParameter.Id / InvalidParameter.Name / .Description / 改名冲突)、403(Forbidden.GroupId:asset group does not belong to you)、500、502、其他上游错误透传

5. 素材 Action​

CreateAsset(异步)​

Request Body(JSON):

字段类型必填说明
GroupIdstring是本人素材组 ID(AIGC 组或真人认证组),否则 403;Action 请求体无 GroupType 参数,按本人全部素材组合集校验
URLstring是素材文件地址,由上游校验
AssetTypestring是Image / Video,由上游校验
Namestring否素材名称

其余字段原样透传上游;ProjectName 会被自动剔除。上游响应原样返回。

Request 示例:

# 上传图片素材(公网 URL,由上游拉取预处理)
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=CreateAsset&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"GroupId": "group-20260928151023-xxxxx", "URL": "https://example.com/reference.png", "AssetType": "Image", "Name": "参考图"}'

# 上传视频素材
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=CreateAsset&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"GroupId": "group-20260928151023-xxxxx", "URL": "https://example.com/clip.mp4", "AssetType": "Video", "Name": "口播片段"}'

重要:创建为异步操作。拿到 Result.Id 后必须轮询 GetAsset,直到 Result.Status 为 Active(成功)或 Failed(失败)。

错误:400(MissingParameter.GroupId)、403(Forbidden.GroupId:group_id does not belong to your asset groups)、502、其他上游错误透传

ListAssets​

Request Body(JSON,官方 Filter 结构):

字段类型必填说明
Filter.GroupTypestring否AIGC(缺省)/ LivenessFace,决定按哪类组过滤
Filter.GroupIdsstring[]否组 ID 列表;缺省查本人该类型全部组;传入须均为本人该类型组,否则 403
Filter.Namestring否素材名称精确匹配,最长 64 字符
Filter.Statusesstring[]否素材状态:Active / Processing / Failed
PageNumber / PageSize / SortBy / SortOrder / NextToken / MaxResults—否分页与排序规则同 ListAssetGroups;SortBy 额外支持 GroupId

Request 示例:

# 官方数组格式:查指定组的可用素材,第 1 页 20 条
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=ListAssets&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Filter":{"GroupIds":["group-20260928151023-xxxxx"],"Statuses":["Active"]},"PageNumber":1,"PageSize":20}'

# 宽松兼容格式:GroupIds 单个字符串(逗号分隔多组),按更新时间倒序
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=ListAssets&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Filter":{"GroupIds":"group-20260928151023-xxxxx,group-20260929155735-yyyyy"},"PageNumber":1,"PageSize":20,"SortBy":"UpdateTime","SortOrder":"Desc"}'

# 游标分页:用上一页响应的 Result.NextToken 翻页
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=ListAssets&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Filter":{"GroupType":"AIGC"},"NextToken":"Mg==","MaxResults":20}'

Response 200:结构同 ListAssetGroups(Result.Items 为上游透传的完整素材字段:Id / GroupId / Name / AssetType / Status / URL / CreateTime / UpdateTime 等)。

说明:

  • 上游列表不区分用户,网关始终按本人素材组 + Name / Statuses 兜底过滤
  • 上游错误(含官方参数错误)原样透传,无数据库回退(素材元数据仅存于上游)
  • 本人无对应类型素材组时直接返回空列表(不查上游)

错误:400(InvalidParameter.GroupType / .Name / .Statuses / .SortBy / .SortOrder / .PageSize)、403(Forbidden.GroupIds)、500、502、其他上游错误透传

GetAsset / UpdateAsset / DeleteAsset​

Request Body(JSON):

字段类型必填说明
Idstring是素材 ID
其他字段—否UpdateAsset 可修改字段(如 Name)原样透传上游;ProjectName 自动剔除

说明:

  • 网关先经上游 GetAsset 查素材所属 GroupId 做归属预检:素材不存在或 Id 非法等上游错误原样透传;素材不属于本人素材组返回 403 Forbidden.AssetId
  • GetAsset 直接返回预检结果;UpdateAsset / DeleteAsset 在预检通过后透传原始请求
# GetAsset:查详情 / 轮询预处理状态(Status: Processing → Active / Failed)
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=GetAsset&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "asset-20260928160000-xxxxx"}'

# UpdateAsset:改素材名(其他可修改字段原样透传)
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=UpdateAsset&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "asset-20260928160000-xxxxx", "Name": "新素材名"}'

# DeleteAsset:删除素材
curl -X POST 'https://token.taiha.cn/api/seedance/proxy/openapi?Action=DeleteAsset&Version=2024-01-01' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-xxx' \
-d '{"Id": "asset-20260928160000-xxxxx"}'

错误:400(MissingParameter.Id)、403(Forbidden.AssetId:asset not found in your asset group)、502、其他上游错误透传

6. 典型调用流程​

1. POST /api/seedance/proxy/openapi?Action=CreateAssetGroup → 得到 Result.Id(group_id)
2. POST /api/seedance/proxy/openapi?Action=CreateAsset → 携带 GroupId,得到 Result.Id(asset_id)
3. POST /api/seedance/proxy/openapi?Action=GetAsset → 轮询,直至 Result.Status = Active / Failed

7. 错误格式​

入口层错误(方法 / Action 白名单 / JSON 解析,对齐上游 openapi 入口格式):

{ "error": "official_openapi_requires_post", "request_id": "0f1e2d3c-xxxx" }
状态码error场景
405official_openapi_requires_post非 POST 方法
403official_action_not_allowedAction 缺失或不在白名单
400invalid_json请求体非合法 JSON(空请求体按 {} 处理)

网关侧校验错误(参数与归属校验,官方 ResponseMetadata.Error 结构):

{
"ResponseMetadata": {
"RequestId": "...", "Action": "CreateAssetGroup", "Version": "2024-01-01",
"Service": "ark", "Region": "cn-beijing",
"Error": { "Code": "MissingParameter.Name", "Message": "The required parameter Name is missing.", "Data": null }
}
}
状态码Code场景
400MissingParameter.Name / .Id / .GroupId必填字段缺失
400InvalidParameter.Name / .Description超长、重名
400InvalidParameter.GroupType建组仅支持 AIGC;列表类型取值非法
400InvalidParameter.SortBy / .SortOrder / .PageSize / .Statuses取值非法
403Forbidden.GroupId素材组不属于本人
403Forbidden.GroupIdsGroupIds 含非本人素材组
403Forbidden.AssetId素材不属于本人素材组
403ServiceUnavailable素材库代理未启用
500InternalError网关内部错误(数据库等)/ 上游 key 未配置
502UpstreamError上游不可用或上游响应无效

上游错误:状态码与响应体原样透传(含官方业务错误,如 NotFound.group_id 等 ResponseMetadata.Error 结构)。

令牌无效:401(网关标准认证错误格式,与其他 API 令牌接口一致)。