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

# Hailuo 2.3 API：Standard 和 Pro 影片生成模式

> Hailuo 2.3 影片生成 API 適用於標準和專業文字到影片和影像到影片工作流程

## 概覽

Hailuo 2.3 可根據文字提示詞生成影片，也可以用單張圖片作為首影格。在 APIXO Playground 試用後，可依本頁範例呼叫 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `hailuo-2-3` |
| 模式 | `standard-text-to-video`, `standard-image-to-video`, `pro-text-to-video`, `pro-image-to-video` |
| 提示詞 | 非空字串 |
| 參考圖片 | 對於影像到影片模式，精確為 1 個 URL |
| 輸出解析度 | 標準模式：`768p`；專業模式：`1080p` |
| 輸出持續時間 | 標準模式：`6` 或 `10` 秒；專業模式：固定 `5` 秒 |
| 結果格式 | MP4 URL 陣列位於 `resultJson.resultUrls` 中 |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/hailuo-2-3` | 送出生成任務 |
| `GET` | `/statusTask/hailuo-2-3?taskId={taskId}` | 查詢任務狀態並取得結果 |

每個請求都必須附上 APIXO API 金鑰：

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

送出任務時，還需設定以下請求標頭：

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

## 非同步請求範例

此最小請求提交標準文字到影片任務並傳回 `taskId`

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/hailuo-2-3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "standard-text-to-video",
      "prompt": "a dramatic sunrise over a futuristic skyline with slow cinematic camera movement",
      "duration": 6
    }
  }'
```

成功回應：

```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/hailuo-2-3?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": 1767965730929,
    "costTime": 120000
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "PromptInvalid",
    "failMsg": "Prompt is invalid or rejected",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9041
  }
}
```

等 `state` 變為 `success` 後，再解析 `resultJson`：

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

## 請求體

### 標準文字轉影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "standard-text-to-video",
    "prompt": "a dramatic sunrise over a futuristic skyline with slow cinematic camera movement",
    "duration": 6
  }
}
```

### 標準圖生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "standard-image-to-video",
    "prompt": "make this still image move naturally with cinematic camera motion",
    "image_urls": [
      "https://example.com/input.jpg"
    ],
    "duration": 10
  }
}
```

### 專業文字轉影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "pro-text-to-video",
    "prompt": "a premium commercial shot of a glass perfume bottle with elegant camera movement"
  }
}
```

### 專業影像轉影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "pro-image-to-video",
    "prompt": "smoothly animate this image with a subtle camera push-in and natural lighting variation",
    "image_urls": [
      "https://example.com/input.jpg"
    ]
  }
}
```

## 參數

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

取得結果的方式。選擇 `async` 時，透過 `statusTask` 輪詢結果；選擇 `callback` 時，透過 Webhook 接收結果。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必填。請提供可從網際網路存取的 HTTPS 網址，以接收任務的最終結果。詳見 [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

**input** `object` *required*

Hailuo 2.3 的輸入參數。

**屬性**

**mode** `string` *required*

生成模式。可用值為 `standard-text-to-video`、`standard-image-to-video`、`pro-text-to-video`、`pro-image-to-video`。

**prompt** `string` *required*

描述影片的文字提示。必須是非空字串，且不超過 2,000 UTF-8 位元組。最大長度：2000 UTF-8 位元組。

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

對於 `standard-image-to-video` 和 `pro-image-to-video` 是必需的。後端正好需要 1 個非空影像 URL。支援的格式有 JPG、JPEG 和 PNG。每個影像不得大於 20 MB，兩個尺寸必須大於 300 像素，且寬度除以高度必須大於 0.4 且小於 2.5。文字轉影片模式忽略此欄位。

**duration** `integer|string`

標準模式所需。支援的值：`6`、`10`、`"6"` 或 `"10"`。專業模式具有固定的 5 秒輸出，並忽略 `duration`（如果存在）。

| 模式 | 所需媒體 | `duration` 行為 | 輸出 |
| - | - | - | - |
| `standard-text-to-video` | 無 | 所需：`6` 或 `10` 秒 | `768p`影片 |
| `standard-image-to-video` | 正好 1 影像 URL | 所需：`6` 或 `10` 秒 | `768p`影片 |
| `pro-text-to-video` | 無 | 被忽略 | 固定 5 秒 `1080p` 影片 |
| `pro-image-to-video` | 正好 1 影像 URL | 被忽略 | 固定 5 秒 `1080p` 影片 |

> [!TIP]
>
> 在圖生影片中，使用提供的影像作為第一影格。請直接提供JPG、JPEG或PNG的URL；圖像驗證可能拒絕超過20MB的圖像、短邊小於或等於300px的圖像，或寬高比超出2:5至5:2範圍的圖像。

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/hailuo-2-3` 會傳回任務 ID：

**code** `integer`

API 狀態碼。`200` 表示任務已受理。

**message** `string`

狀態說明。

**data.taskId** `string`

任務的唯一 ID，用於查詢任務狀態。

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

目前的任務狀態，可能的值為 `processing`、`success`、`failed`。

**resultJson** `string`

當 `state` 為 `success` 時傳回。解析此 JSON 字串後，即可從 `resultUrls` 取得生成的影片連結。

**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/hailuo-2-3" \
  -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": "pro-image-to-video",
      "prompt": "animate this product image with a clean studio camera move",
      "image_urls": [
        "https://example.com/product.jpg"
      ]
    }
  }'
```

回呼有效負載會複製最終狀態回應的結構，包含 `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)。

Hailuo 2.3 的計費依據所選的模式家族。

| 模式家族 | APIXO 價格 | 計費規則 | 收費範例 |
| - | - | - | - |
| 標準模式 | `$0.056 / second` | `duration * $0.056` | 6s: `$0.336`; 10s: `$0.56` |
| 專業模式 | `$0.49 / use` | 每代固定價格 | 固定5秒輸出：`$0.49` |

最新的美元費率請見 [API 價目表](https://apixo.ai/pricing/api)。

## 耗時與輪詢

實際延遲可能會因提示複雜性、影像可存取性、模式、佇列負載和生成時間而異。當計時資料可用時，狀態回應在完成後以毫秒為單位報告 `costTime`。

| 模式家族 | 輸出持續時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| 標準模式 | 6s或10s | 任務建立 30 秒後 | 10s-15s |
| 專業模式 | 固定5s | 任務建立 45 至 60 秒後 | 10s-15s |

> [!TIP]
>
> 對於高並行度生產工作負載，請使用回呼模式以避免對長時間運行的影片任務進行頻繁輪詢。

請求頻率與並行數上限會依帳戶、API 金鑰和路由而異。收到 `429` 時，請降低請求頻率，並逐步拉長重試間隔。帳戶層級的限制請見[系統 API](https://apixo.ai/docs/zh-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、缺少 `input`、不受支援的 `mode`、無效 `duration` 或無效影像 URL 形狀 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤或未知任務失敗 | 逐步拉長間隔後重試 |
| `502` | 服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 服務超時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

### 驗證說明

| 條件 | 後端行為 |
| - | - |
| 缺少 `input` | 任務建立前請求失敗 |
| 缺失或為空 `prompt` | 任務建立前請求失敗 |
| 不支援的 `mode` 值 | 任務建立前請求失敗 |
| 無`image_urls`的影像模式 | 任務建立前請求失敗 |
| `image_urls` 為空，或包含超過 1 個條目 | 任務建立前請求失敗 |
| 標準模式無`duration` | 任務建立前請求失敗 |
| 持續時間除 `6` 或 `10` 之外的標準模式 | 任務建立前請求失敗 |
| 專業模式帶`duration` | `duration`被忽略 |

### 任務失敗代碼

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `PromptInvalid` | 提示被拒絕或格式錯誤 | 調整提示並重試 |
| `SensitiveContent` / `InputOutputSensitiveContentDetected` | 提示、輸入影像或輸出內容檢查失敗 | 更改提示或輸入影像 |
| `ImageFormatIncorrect` / `InvalidImageSize` | 輸入影像影像驗證失敗 | 在記錄的尺寸和縱橫比限制內使用公共 JPG/JPEG/PNG URL |
| `RateLimited` | 請求頻率已達上限 | 以指數退避方式重試 |
| `Timeout` | 任務逾時 | 重試、簡化請求或使用回呼方式 |
| `Unknown error` | 任務因不明原因失敗 | 逐步拉長間隔後重試，或聯絡支援團隊並提供 `taskId` |

完整列表見[錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)。

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/hailuo-2-3.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_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)
* [嘗試 Hailuo 2.3 在 APIXO Playground](https://apixo.ai/models/hailuo-2-3)
* [API定價](https://apixo.ai/pricing/api)


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