curl --request POST \
--url https://api.tokenlab.sh/v1/videos/assets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_url": "https://example.com/reference.png",
"asset_name": "Front view",
"asset_type": "Image",
"library_type": "aigc_avatar",
"group_id": "group-20260720123456-vrt01"
}
'
{
"id": "asset-20260720123456-qn7wr",
"object": "seedance.material_asset",
"group_id": "group-20260720123456-vrt01",
"library_type": "aigc_avatar",
"asset_name": "Front view",
"asset_type": "Image",
"status": "PROCESSING",
"ready": false,
"error_message": null,
"metadata": null,
"created_at": 1782998400000
}{
"error": {
"message": "model: Model is required",
"type": "invalid_request_error",
"param": "model"
},
"validation_errors": [
{
"field": "model",
"message": "Model is required"
}
]
}{
"error": {
"message": "Invalid API key provided",
"type": "invalid_api_key"
}
}{
"error": {
"message": "<string>",
"type": "unauthorized",
"code": "<string>",
"param": "<string>",
"model": "<string>",
"did_you_mean": "<string>",
"suggestions": [
{
"id": "<string>"
}
],
"alternatives": [
{
"id": "<string>",
"status": "<string>",
"tags": [
"<string>"
]
}
],
"hint": "<string>",
"retry_after": 123,
"retryable": true,
"balance_usd": 123,
"estimated_cost_usd": 123,
"supported_operations": [
"<string>"
],
"supported_parameters": [
"<string>"
],
"required_selectors": [
"<string>"
],
"optional_selectors": [
"<string>"
],
"allowed_resolutions": [
"<string>"
],
"allowed_durations": [
"<string>"
],
"allowed_aspect_ratios": [
"<string>"
],
"prompt_max_characters": 123,
"recommended_request": {},
"request_endpoint": "<string>",
"request_shape_mode": "<string>",
"status_mode": "<string>",
"request_id": "<string>"
}
}{
"error": {
"message": "An internal error occurred",
"type": "server_error"
}
}{
"error": {
"message": "Seedance material library request failed",
"type": "server_error",
"code": "seedance_material_library_request_failed"
}
}視頻與素材
建立素材資產
將 Seedance 素材資產上傳至 TokenLab 素材群組。
POST
/
v1
/
videos
/
assets
curl --request POST \
--url https://api.tokenlab.sh/v1/videos/assets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_url": "https://example.com/reference.png",
"asset_name": "Front view",
"asset_type": "Image",
"library_type": "aigc_avatar",
"group_id": "group-20260720123456-vrt01"
}
'
{
"id": "asset-20260720123456-qn7wr",
"object": "seedance.material_asset",
"group_id": "group-20260720123456-vrt01",
"library_type": "aigc_avatar",
"asset_name": "Front view",
"asset_type": "Image",
"status": "PROCESSING",
"ready": false,
"error_message": null,
"metadata": null,
"created_at": 1782998400000
}{
"error": {
"message": "model: Model is required",
"type": "invalid_request_error",
"param": "model"
},
"validation_errors": [
{
"field": "model",
"message": "Model is required"
}
]
}{
"error": {
"message": "Invalid API key provided",
"type": "invalid_api_key"
}
}{
"error": {
"message": "<string>",
"type": "unauthorized",
"code": "<string>",
"param": "<string>",
"model": "<string>",
"did_you_mean": "<string>",
"suggestions": [
{
"id": "<string>"
}
],
"alternatives": [
{
"id": "<string>",
"status": "<string>",
"tags": [
"<string>"
]
}
],
"hint": "<string>",
"retry_after": 123,
"retryable": true,
"balance_usd": 123,
"estimated_cost_usd": 123,
"supported_operations": [
"<string>"
],
"supported_parameters": [
"<string>"
],
"required_selectors": [
"<string>"
],
"optional_selectors": [
"<string>"
],
"allowed_resolutions": [
"<string>"
],
"allowed_durations": [
"<string>"
],
"allowed_aspect_ratios": [
"<string>"
],
"prompt_max_characters": 123,
"recommended_request": {},
"request_endpoint": "<string>",
"request_shape_mode": "<string>",
"status_mode": "<string>",
"request_id": "<string>"
}
}{
"error": {
"message": "An internal error occurred",
"type": "server_error"
}
}{
"error": {
"message": "Seedance material library request failed",
"type": "server_error",
"code": "seedance_material_library_request_failed"
}
}將一個可公開存取的來源 URL 匯入至 Seedance 素材群組。TokenLab 會儲存該素材以供後續使用;請使用回傳的素材資產
TokenLab 會檢查來源 URL、媒體類型、檔案大小和可讀取的圖片尺寸。接受匯入不代表素材已就緒:請等待
id 進行生成,而非使用來源 URL。
對於 library_type: "aigc_avatar",group_id 為選填;TokenLab 將使用或建立組織預設的虛擬人像群組。對於 library_type: "liveness_face",group_id 為必填,且必須是透過 取得視覺驗證結果 所回傳的 TokenLab 群組。
| 類型 | 支援的輸入 |
|---|---|
| 圖片 | jpeg, jpg, png, webp, bmp, tiff, gif, heic, heif; ≤30 MiB; 寬度和高度 [300, 6000] px; 寬高比 [0.4, 2.5]. |
| 影片 | mp4, mov; ≤200 MiB. |
| 音訊 | aac, wav, mp3; ≤15 MiB. |
ACTIVE,處理失敗時查看 error_message。其他媒體及人臉要求在處理期間驗證。
建立過程為非同步。請輪詢 取得素材資產 直到 status 變為 ACTIVE。對於真人群組,一個群組對應一個已驗證的人員;若上傳包含多張人臉或與已驗證人員不符的人臉,可能會導致失敗。
project_name 用於同一組織內的資源隔離,預設為 default。相關素材群組和素材須使用相同且區分大小寫的值;POST/PUT 在 JSON 請求主體中傳入,GET/DELETE 在查詢參數中傳入。
請求範例
curl https://api.tokenlab.sh/v1/videos/assets \
-H "Authorization: Bearer $TOKENLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"library_type":"aigc_avatar","group_id":"group-20260720123456-vrt01","asset_url":"https://example.com/reference.png","asset_type":"Image","asset_name":"Front view","project_name":"default"}'
回應範例
{
"id": "asset-20260720123456-qn7wr",
"object": "seedance.material_asset",
"project_name": "default",
"group_id": "group-20260720123456-vrt01",
"library_type": "aigc_avatar",
"asset_name": "Front view",
"asset_type": "Image",
"status": "PROCESSING",
"ready": false,
"error_message": null,
"metadata": null,
"created_at": 1782998400000
}
授權
API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。
主體
application/json
可公開存取的匯入來源 URL。TokenLab 會儲存該素材以供後續使用;請勿將此 URL 視為長期的素材位址。
隨素材資源儲存的選用顯示名稱。
Required string length:
1 - 128可用選項:
Image, Video, Audio 素材庫類別。aigc_avatar 用於虛擬化身素材。liveness_face 用於已驗證的真人素材。
可用選項:
aigc_avatar, liveness_face TokenLab 素材群組 ID。liveness_face 素材為必填;aigc_avatar 則為選填。
素材資源的專案範圍。資源與群組在已驗證組織內的專案中是隔離的。
Required string length:
1 - 128隨素材資源儲存的選用客戶中繼資料。
回應
素材資產已建立
TokenLab 素材資源 ID。在資源變為 ACTIVE 後,請將此作為 material_asset_id 使用。
可用選項:
seedance.material_asset 可用選項:
aigc_avatar, liveness_face 可用選項:
Image, Video, Audio 可用選項:
PROCESSING, ACTIVE, FAILED, DELETED 當資源為啟用且未刪除時為 True。
擁有此素材資源的 TokenLab 素材群組 ID。
此素材資源的專案範圍。
可公開顯示的終端處理錯誤。永久性來源驗證失敗包含被拒絕的尺寸限制。
建立素材資源記錄時的 Unix 時間戳記。
最後更新素材資源記錄時的 Unix 時間戳記。