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

# InfiniteTalk API：用音频驱动虚拟形象说话

> 从肖像图像生成音频驱动的会说话的头像视频：对话式剪辑的同步语音和表情。

## 概览

从一张肖像和一首演讲或歌曲开始。将肖像放入第一个 `image_urls` 插槽中，并提供一个可公开访问的 MP3、WAV 或 M4A 音频 URL。提交之前，请检查曲目是否在两个限制内：128 MB 和 600 秒。

对于基本的说话肖像，请遵循 [图生视频示例](#image-to-video)。如果您还有面具，请使用 [双图像示例](#with-an-optional-mask-image) 使肖像和面具保持正确的顺序。

| 功能 | 值 |
| - | - |
| 模型 ID | `infinitetalk` |
| 模式 | `image-to-video` |
| 源图像 | 1 所需图像 URL，加上 1 可选遮罩图像 URL |
| 音频输入 | 正好 1 公开 HTTP(S) MP3、WAV 或 M4A URL |
| 音频限制 | 最多 128 MB 和 600 秒 |
| 可选分辨率 | `480p`, `720p` |
| 计费 | 每探测音频秒，最少 5 秒 |

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/infinitetalk` | 提交生成任务 |
| `GET` | `/statusTask/infinitetalk?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

此最小请求提交 InfiniteTalk 任务并返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/infinitetalk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "image-to-video",
      "image_urls": [
        "https://example.com/portrait.png"
      ],
      "audio_urls": [
        "https://example.com/voice.mp3"
      ],
      "prompt": "make the portrait speak naturally with subtle head motion",
      "resolution": "480p",
      "seed": -1
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/infinitetalk?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates safety policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 请求体

### 图生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "image_urls": [
      "https://example.com/portrait.png"
    ],
    "audio_urls": [
      "https://example.com/voice.m4a"
    ],
    "prompt": "keep the face stable while syncing lips to the audio",
    "resolution": "480p",
    "seed": -1
  }
}
```

### 带有可选的蒙版图像

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "image_urls": [
      "https://example.com/portrait.png",
      "https://example.com/mask.png"
    ],
    "audio_urls": [
      "https://example.com/voice.wav"
    ],
    "prompt": "subtle head motion, natural eye movement",
    "resolution": "720p",
    "seed": 7
  }
}
```

`image_urls[0]` 是源肖像。`image_urls[1]`（如果提供）是掩模图像。

## 参数

**request\_type** `string` (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当`request_type`为`callback`时需要。使用可以接收最终任务负载的公共端点。请参阅 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

InfiniteTalk 的输入参数。

**属性**

**mode** `string` *required*

生成模式。仅支持 `image-to-video`。

**image\_urls** `string[]` *required*

对于 [说话的肖像](#image-to-video)，请在此处发送一张肖像 URL，并在 `audio_urls` 中发送语音轨迹。对于 [蒙版动画](#with-an-optional-mask-image)，将蒙版附加为第二个图像。将肖像保留在第一个插槽中。

**audio\_urls** `string[]` *required*

音频 URL 列表。必须恰好包含 1 个公共 HTTP(S) URL。音频必须为 MP3、WAV 或 M4A，大小不超过 128 MB，时长不超过 600 秒。

**prompt** `string`

表情、动作或场景指导的可选提示。如果提供，必须是非空字符串。最大长度：5000 个字符。

**resolution** `string` (default: 480p)

输出分辨率。支持的值：`480p`、`720p`。值将被标准化为小写。

**seed** `integer` (default: -1)

随机种子。使用 `-1` 生成随机输出，或使用 `0` 到 `2147483647` 之间的整数进行可重现生成。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/infinitetalk` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

JSON 字符串，包含生成的视频 URL，如 `resultUrls`。当 `state` 为 `success` 时存在。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理时间以毫秒为单位。成功完成后若可用则返回。

## Webhook 回调模式

如果希望服务端自动收到最终结果，可以使用回调模式，无需轮询。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/infinitetalk" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "image-to-video",
      "image_urls": [
        "https://example.com/portrait.png"
      ],
      "audio_urls": [
        "https://example.com/voice.mp3"
      ],
      "prompt": "natural speech with subtle head movement",
      "resolution": "720p",
      "seed": -1
    }
  }'
```

回调有效负载使用与状态响应相同的 `code`、`message` 和 `data` 形状。请参阅 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md) 了解传送要求和重试行为。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

InfiniteTalk 按参考音频的实际时长计费，最低计费单位为 5 秒。

```text theme={null}
billableSeconds = max(5, actualAudioSeconds)
totalCost = billableSeconds * resolutionUnitPrice
```

| 分辨率 | APIXO 价格 |
| - | - |
| `480p` | `$0.03 / second` |
| `720p` | `$0.06 / second` |

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟因音频长度、所选分辨率、队列负载和最终结果存储而异。较长的音频通常需要更长的时间才能完成。

| 音频长度 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| 最多 30 秒 | 任务创建 30 秒后 | 10s-15s |
| 30s-120s | 任务创建 60 秒后 | 15s-30s |
| 120s-600s | 任务创建 120 秒后 | 30s |

> [!TIP]
>
> 对于生产工作负载，尤其是长音频，请使用回调模式以避免频繁轮询。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体无效、模式不受支持、参数类型或值无效、无法访问 URL 或音频探测器故障 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知任务失败 | 逐步延长间隔后重试 |
| `502` | 服务错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 常见验证问题

| 问题 | 发生了什么 | 处理方式 |
| - | - | - |
| 缺少 `input.mode` | InfiniteTalk 需要 `image-to-video` 模式 | 将 `input.mode` 设置为 `image-to-video` |
| `image_urls` 长度无效 | 后端接受 1 或 2 个图像 URL | 先发送肖像 URL，然后发送可选的蒙版 URL |
| `audio_urls` 长度无效 | 后端必须接受恰好 1 个音频 URL | 发送单个 MP3、WAV 或 M4A URL |
| 无法获取音频 | 计费前后端必须获取音频 | 使用公开的 HTTP(S) 直接 URL |
| 音频太大或太长 | 音频限制为 128 MB 和 600 秒 | 缩短或压缩音频 |
| 空提示 | `prompt` 是可选的，但如果存在则不能为空 | 删除该字段或发送非空字符串 |
| 无效种子 | `seed` 必须是 `-1` 到 `2147483647` 之间的整数 | 使用 `-1` 或有效整数 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `SensitiveContent` | 提示或媒体未通过安全检查 | 更改提示、源图像或音频 |
| `PromptInvalid` | 提示词无效或被拒绝 | 简化提示并重试 |
| `RateLimited` | 请求频率达到上限 | 逐步延长间隔后重试 |
| `Timeout` | 任务超时 | 重试、降低输入复杂度或使用回调模式 |
| `MissingParameter`或`BadRequest` | 请求格式错误 | 重新检查请求体 |
| `Unknown error` | 任务因未知原因失败 | 逐步延长间隔后重试，或联系支持团队并提供 `taskId` |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/infinitetalk.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_urls`, `audio_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [视频模型](https://apixo.ai/docs/zh/models/video)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [在 APIXO Playground 尝试 InfiniteTalk](https://apixo.ai/models/infinitetalk)
* [API定价](https://apixo.ai/pricing/api)


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