> ## 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.