> ## Documentation Index
> Fetch the complete documentation index at: https://docs.acedata.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Digital Human 影片生成 API

> Digital Human 整合指南 - Ace Data Cloud

透過 `POST /digital-human/videos` 將人物影片或照片與音訊合成為唇形同步的影片。

## 準備影片生成請求

從[應用程式列表](https://platform.acedata.cloud/console/applications)的通用應用程式複製 API Key。範例使用同一份 Key 提交影片和查詢合成進度，如果設定了介面範圍，請同時允許這兩項操作。生成費用可在 [Digital Human 價格頁面](https://platform.acedata.cloud/services/digitalhuman?tab=pricing)查看。

## 生成第一個影片

準備可公開存取的人物影片和驅動音訊 URL，將下方 `YOUR_FACE_VIDEO_URL`、`YOUR_AUDIO_URL` 替換為自己的素材。照片輸入使用 `image_url`。範例先選擇影片和音訊組合。

```bash theme={null}
export ACEDATACLOUD_API_KEY="YOUR_API_KEY"
curl --request POST 'https://api.acedata.cloud/digital-human/videos' \
  --header "Authorization: Bearer $ACEDATACLOUD_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "video_url": "YOUR_FACE_VIDEO_URL",
    "audio_url": "YOUR_AUDIO_URL",
    "async": true
  }'
```

### 提交回應 JSON

以下依公開回應契約展示，任務 ID 與 trace\_id 使用你的實際回傳值。

```json theme={null}
{
  "success": true,
  "task_id": "YOUR_TASK_ID",
  "trace_id": "YOUR_TRACE_ID",
  "state": "pending"
}
```

儲存提交回應中的 `task_id`。影片仍在處理中時，繼續查詢同一任務。

## 查詢並下載結果

```bash theme={null}
curl --request POST 'https://api.acedata.cloud/digital-human/tasks' \
  --header "Authorization: Bearer $ACEDATACLOUD_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"task_id":"YOUR_TASK_ID"}'
```

### 處理中回應 JSON

```json theme={null}
{
  "success": true,
  "task_id": "YOUR_TASK_ID",
  "trace_id": "YOUR_TRACE_ID",
  "state": "pending",
  "progress": 0
}
```

### 完成回應 JSON

以下節錄公開介面中的回應範例。

```json theme={null}
{
  "success": true,
  "task_id": "task_...",
  "trace_id": "...",
  "state": "succeed",
  "progress": 100,
  "video_url": "https://cdn.acedata.cloud/634d760216.mp4",
  "duration": 17.2,
  "width": 1280,
  "height": 720
}
```

輪詢時省略 `action` 可取得平鋪結果，包含 `state`、`progress`，以及完成後的 `video_url`、`duration`、`width`、`height`。`state` 為 `succeed` 時讀取並儲存 `video_url`，為 `failed` 時讀取 `error` 並停止輪詢。查詢請求本身的 `success` 不代表影片已經生成完成。處理中可每隔數秒繼續查詢。

使用 `action=retrieve` 則取得詳細任務記錄，最終結果位於 `response`。完整查詢方式見[任務查詢指南](https://platform.acedata.cloud/documents/digitalhuman-tasks-integration)。

## 輸入和更多操作

* 人物素材可使用 `video_url` 或 `image_url`，音訊素材使用 `audio_url`。
* 文字驅動使用 `text` 和已建立的 `voice_id`。建立聲音的參數見[聲音 API](https://platform.acedata.cloud/documents/digitalhuman-voices)。
* `callback_url` 可接收完成回呼，回呼與主動查詢應依同一個任務 ID 對應。
* 更多參數及目前限制見[影片 API 參考](https://platform.acedata.cloud/documents/digitalhuman-videos)。

## 錯誤處理

輸入錯誤時核對素材 URL 和所選輸入組合。認證或餘額錯誤時檢查 API Key 所屬的應用程式、權限、有效期限與餘額。請求逾時後，已取得 `task_id` 的任務應先查詢原任務。聯絡支援時提供 `trace_id` 和任務 ID。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.