Instant Avatar API
Tổng Quan
Giới thiệu
Instant Avatar API của AusyncLab cho phép tạo video avatar biết nói từ hình ảnh tĩnh. Sử dụng công nghệ AI tiên tiến để tạo chuyển động môi, biểu cảm và cử động đầu đồng bộ với âm thanh.
Tính Năng Chính
- Tạo avatar từ hình ảnh tĩnh (PNG, JPG)
- Đồng bộ chuyển động môi với audio
- Tạo biểu cảm và cử động đầu tự nhiên
- Hỗ trợ nhiều định dạng audio input
- Callback URL để theo dõi tiến trình
Quick Start
- Đăng ký và lấy API Key từ hệ thống.
- Tải lên hình ảnh avatar thông qua endpoint
/register. - Tạo video từ avatar và file audio.
- Nhận thông báo qua callback khi video hoàn thành.
Xác Thực
API yêu cầu cung cấp API Key qua header X-API-Key. API Key phải được bảo mật và không chia sẻ công khai.
Base URLs
https://api.ausynclab.io/api/v1/avatars
https://api.ausynclab.io/api/v1/avatar-videosPlayground
Thử nghiệm API tại: https://api.ausynclab.io/docs (opens in a new tab)
Chi Tiết Endpoints
1. Tạo Avatar
URL: https://api.ausynclab.io/api/v1/avatars/register
Phương thức: POST
Mô tả: Đăng ký một avatar tùy chỉnh mới.
Tham số Query:
name(bắt buộc): Tên của avatar.
Body:
Tải lên file avatar dưới dạng multipart/form-data.
CURL:
curl -X 'POST' \
'http://api.ausynclab.io/api/v1/avatars/register?name=demo' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key' \
-H 'Content-Type: multipart/form-data' \
-F 'avatar_file=@sample.png;type=image/pngPhản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "123e4567-e89b-12d3-a456-426614174001"
}
}- 404 Not Found: Không thể tạo avatar.
2. Lấy Thông Tin Chi Tiết Avatar
URL: https://api.ausynclab.io/api/v1/avatars/{avatar_id}
Phương thức: GET
Mô tả: Lấy thông tin chi tiết của một avatar cụ thể.
Tham số:
avatar_id(bắt buộc): ID của avatar (kiểu UUID).
CURL:
curl -X 'GET' \
'http://api.ausynclab.io/api/v1/avatars/a9t8f34d-b6f4-4c5f-a003-0f5eceee6b4c' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "a9t8f34d-b6f4-4c5f-a003-0f5eceee6b4c",
"name": "Avatar 1",
"avatar_url": "https://cdn-ausync-endpoint.azureedge.net/avatar/sample.jpeg",
"created_at": "2025-01-04T08:33:42"
}
}- 404 Not Found: Avatar không tồn tại.
3. Lấy Danh Sách Avatar
URL: https://api.ausynclab.io/api/v1/avatars/list
Phương thức: GET
Mô tả: Lấy danh sách các avatar của người dùng.
CURL:
curl -X 'GET' \
'https://api.ausynclab.io/api/v1/avatars/list' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": [
{
"id": "a9t8f34d-b6f4-4c5f-a003-0f5eceee6b4c",
"name": "Avatar 1",
"avatar_url": "https://cdn-ausync-endpoint.azureedge.net/avatar/sample.jpeg",
"created_at": "2025-01-04T08:33:42"
},
{
"id": "2a9ebd5a-7824-48d3-9f01-1a243f5bed75",
"name": "Avatar 2",
"avatar_url": "https://cdn-ausync-endpoint.azureedge.net/avatar/sample2.png",
"created_at": "2025-01-04T08:30:21"
},
...
]
}- 404 Not Found: Không tìm thấy danh sách avatar.
4. Xóa Avatar
URL: https://api.ausynclab.io/api/v1/avatars/{avatar_id}
Phương thức: DELETE
Mô tả: Xóa một avatar cụ thể theo ID.
Tham số:
avatar_id(bắt buộc): ID của avatar (kiểu UUID).
CURL:
curl -X 'DELETE' \
'https://api.ausynclab.io/api/v1/avatars/a8b8f34d-b6f4-4c5f-a003-0f5eceee6b4c' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "a8b8f34d-b6f4-4c5f-a003-0f5eceee6b4c",
"message": "The avatar is successfully deleted."
}
}- 404 Not Found: Không tìm thấy avatar.
5. Tạo Avatar Video
URL: https://api.ausynclab.io/api/v1/avatar-videos/generate
Phương thức: POST
Mô tả: Tạo video từ avatar và file âm thanh.
Body:
{
"name": "Sample Video", // Tên video (bắt buộc)
"avatar_id": "123e4567-e89b-12d3-a456-426614174000", // ID của avatar (UUID, bắt buộc)
"audio_url": "https://example.com/audio.wav", // URL của file âm thanh (bắt buộc)
"callback_url": "https://your-callback-url.com" // URL được gọi khi Instant Avatar job hoàn thành (bắt buộc)
}
**CURL**:
```bash
curl -X 'POST' \
'https://api.ausynclab.io/api/v1/avatar-videos/generate' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key' \
-d '{
"name": "Sample Video",
"avatar_id": "123e4567-e89b-12d3-a456-426614174000",
"audio_url": "https://example.com/audio.wav",
"callback_url": "https://your-callback-url.com"
}'Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "123e4567-e89b-12d3-a456-426614174001"
}
}- 404 Not Found: Không thể tạo video.
- 422 Validation Error: Dữ liệu không hợp lệ.
6. Lấy Thông Tin Chi Tiết Avatar Video
URL: https://api.ausynclab.io/api/v1/avatar-videos/{video_id}
Phương thức: GET
Mô tả: Lấy thông tin chi tiết của một avatar cụ thể.
Tham số:
video_id(bắt buộc): ID của video (kiểu UUID).
CURL:
curl -X 'GET' \
'http://api.ausynclab.io/api/v1/avatar-videos/fda2b68f-8707-404a-9ad8-c78d60a41b64' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "fda2b68f-8707-404a-9ad8-c78d60a41b64",
"name": "Video 1",
"video_url": "https://cdn-ausync-endpoint.azureedge.net/talking-avatar-video-output/sample.jpeg.mp4",
"created_at": "2025-01-04T08:33:49",
"state": "SUCCEED"
}
}- 404 Not Found: Avatar không tồn tại.
7. Lấy Danh Sách Avatar Video
URL: https://api.ausynclab.io/api/v1/avatar-videos/list
Phương thức: GET
Mô tả: Lấy danh sách các video được tạo bởi người dùng.
CURL:
curl -X 'GET' \
'http://api.ausynclab.io/api/v1/avatar-videos/list' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": [
{
"id": "fda2b68f-8707-404a-9ad8-c78d60a41b64",
"name": "Video 1",
"video_url": "https://cdn-ausync-endpoint.azureedge.net/talking-avatar-video-output/sample1.jpeg.mp4",
"created_at": "2025-01-04T08:33:49",
"state": "SUCCEED"
},
{
"id": "32cb52e6-89fa-43a6-a3df-1508c62f76fd",
"name": "Video 2",
"video_url": "https://cdn-ausync-endpoint.azureedge.net/talking-avatar-video-output/sample2.png.mp4",
"created_at": "2025-01-04T08:30:31",
"state": "SUCCEED"
},
...
]
}- 404 Not Found: Không tìm thấy danh sách video.
8. Xóa Video
URL: https://api.ausynclab.io/api/v1/avatar-videos/{video_id}
Phương thức: DELETE
Mô tả: Xóa một avatar cụ thể theo ID.
Tham số:
video_id(bắt buộc): ID của video (kiểu UUID).
CURL:
curl -X 'DELETE' \
'https://api.ausynclab.io/api/v1/avatar-video/a8b8f34d-b6f4-4c5f-a003-0f5eceee6b4c' \
-H 'accept: application/json' \
-H 'X-API-Key: your_api_key'Phản hồi:
- 200 OK
{
"status": 200,
"result": {
"id": "a8b8f34d-b6f4-4c5f-a003-0f5eceee6b4c",
"message": "The video is successfully deleted."
}
}Callback Payload
Khi job "Tạo Avatar Video" hoàn thành, API sẽ gửi thông báo đến callback_url với payload:
Nội dung Payload:
video_id: ID duy nhất của video đã được tạo.credits_used: Số lượng tín dụng đã sử dụng để xử lý công việc này.status: Trạng thái của công việc ("SUCCEED", "FAILED").video_url: Liên kết để tải xuống video đã được hệ thống tạo.message: Thông báo từ hệ thống về trạng thái xử lý.
Ví dụ
{
"video_id": "123e4567-e89b-12d3-a456-426614174001",
"credits_used": 10,
"status": "SUCCEED",
"video_url": "https://cdn-ausync-endpoint.azureedge.net/talking-avatar-video-output/sample2.png.mp4",
"message": "Your video is generated successfully"
}Lưu ý: Người dùng cần triển khai endpoint để nhận và xử lý payload này.