> ## 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-hant/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`

包含生成影片 URL 的 JSON 字串，欄位為 `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-hant/api-reference/webhooks.md) 以了解傳送要求和重試行為。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/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-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、模式不受支援、參數類型或值無效、無法存取 URL 或音訊偵測器故障 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `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-hant/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-hant/models.md)
* [影片模型](https://apixo.ai/docs/zh-hant/models/video)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)
* [參數規範](https://apixo.ai/docs/zh-hant/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh-hant/concepts/routing-strategies.md)
* [嘗試 InfiniteTalk 在 APIXO Playground](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.