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"
}
}Tạo Tài nguyên Vật liệu
Tải lên một tài nguyên vật liệu Seedance vào một nhóm vật liệu TokenLab.
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"
}
}id tài nguyên vật liệu được trả về để tạo, thay vì sử dụng URL nguồn.
Đối với library_type: "aigc_avatar", group_id là tùy chọn; TokenLab sẽ sử dụng hoặc tạo nhóm avatar ảo mặc định của tổ chức. Đối với library_type: "liveness_face", group_id là bắt buộc và phải là nhóm TokenLab được trả về bởi Lấy kết quả xác thực trực quan.
| Loại | Đầu vào được hỗ trợ |
|---|---|
| Hình ảnh | jpeg, jpg, png, webp, bmp, tiff, gif, heic, heif; ≤30 MiB; chiều rộng và chiều cao [300, 6000] px; tỷ lệ khung hình [0.4, 2.5]. |
| Video | mp4, mov; ≤200 MiB. |
| Âm thanh | aac, wav, mp3; ≤15 MiB. |
ACTIVE và xem error_message nếu xử lý thất bại. Các điều kiện khác về phương tiện và khuôn mặt được kiểm tra trong quá trình xử lý.
Quá trình tạo diễn ra không đồng bộ. Hãy thực hiện poll Lấy tài nguyên vật liệu (Get Material Asset) cho đến khi status là ACTIVE. Đối với các nhóm người thật, một nhóm tương ứng với một người đã được xác minh; việc tải lên có nhiều khuôn mặt hoặc khuôn mặt không khớp với người đã xác minh có thể thất bại.
project_name tách biệt tài nguyên trong tổ chức đã xác thực. Mặc định là default; dùng cùng một giá trị phân biệt chữ hoa, chữ thường cho nhóm và tài nguyên liên quan. Gửi trong nội dung JSON với POST/PUT và tham số truy vấn với GET/DELETE.
Ví dụ Yêu cầu
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"}'
Ví dụ Phản hồi
{
"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
}
Ủy quyền
Xác thực bằng Khóa API. Tạo hoặc quản lý khóa API trong Dashboard > API > API Keys.
Nội dung
URL nguồn có thể truy cập công khai để nhập. TokenLab lưu trữ tài liệu để sử dụng sau; không dựa vào URL này làm địa chỉ tài liệu lâu dài.
Tên hiển thị tùy chọn được lưu trữ cùng với tài sản tài liệu.
1 - 128Image, Video, Audio Lớp thư viện tài liệu. aigc_avatar dành cho tài liệu avatar ảo. liveness_face dành cho tài liệu người thật đã xác minh.
aigc_avatar, liveness_face ID nhóm tài liệu TokenLab. Bắt buộc đối với tài liệu liveness_face; tùy chọn đối với aigc_avatar.
Phạm vi dự án cho tài sản tài liệu. Tài sản và nhóm được cô lập theo dự án bên trong tổ chức đã xác thực.
1 - 128Metadata khách hàng tùy chọn được lưu trữ cùng với tài sản tài liệu.
Phản hồi
Tài nguyên vật liệu đã được tạo
ID tài sản tài liệu TokenLab. Sử dụng ID này làm material_asset_id sau khi tài sản trở thành ACTIVE.
seedance.material_asset aigc_avatar, liveness_face Image, Video, Audio PROCESSING, ACTIVE, FAILED, DELETED True khi tài sản đang hoạt động và không bị xóa.
ID nhóm tài liệu TokenLab sở hữu tài sản tài liệu này.
Phạm vi dự án cho tài sản tài liệu này.
Lỗi xử lý kết thúc an toàn công khai. Các lỗi xác thực nguồn vĩnh viễn bao gồm ràng buộc kích thước bị từ chối.
Dấu thời gian Unix khi bản ghi tài sản tài liệu được tạo.
Dấu thời gian Unix khi bản ghi tài sản tài liệu được cập nhật lần cuối.