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

# Kling 3.0 Omni API：多模式影片生成

> 多模式 Kling 影片生成 API，具備標準、專業和 4K 文字、影像與參考工作流程

## 概覽

Kling 3.0 Omni 對 `input.mode` 中的輸出層與源材料進行編碼。請選擇與任務相符的範例：

* 無資產的提示：[標準文生影片](#standard-text-to-video)。
* 從靜止影像開始的鏡頭：[專業圖生影片](#pro-image-to-video)。
* 用以指導生成的剪輯：[帶參考影片的影片參考](#reference-to-video-with-a-reference-video)。在更動等級前，請先查看單獨的[4K 參考範例](#4k-reference-to-video)；接受的輸入取決於模式。

| 功能 | 值 |
| - | - |
| 模型 ID | `kling-3-0-omni` |
| 模式 | `std-text-to-video`, `std-image-to-video`, `std-reference-to-video`, `pro-text-to-video`, `pro-image-to-video`, `pro-reference-to-video`, `4k-text-to-video`, `4k-image-to-video`, `4k-reference-to-video` |
| 提示詞 | 所有模式皆為必填 |
| 長度 | 預設為`5`；大多數模式支援 `3-15` 秒；`pro-text-to-video`和`pro-image-to-video`支援`5`或`10` |
| 縱橫比 | `16:9`、`9:16`、`1:1` 用於文字與參考模式 |
| 影像輸入 | 影像模式需要1-2張影像；參考模式支援依模式提供參考影像 |
| 影片輸入 | `std-reference-to-video`和`pro-reference-to-video`可使用第一個`video_urls`項目作為參考影片 |
| 輸出 | `resultJson.resultUrls` 中的影片 URL |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/kling-3-0-omni` | 送出生成任務 |
| `GET` | `/statusTask/kling-3-0-omni?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/kling-3-0-omni" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "std-text-to-video",
      "prompt": "a cinematic city skyline at sunset with a slow camera push",
      "duration": 5,
      "sound": false,
      "aspect_ratio": "16:9"
    }
  }'
```

成功回應：

```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/kling-3-0-omni?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": "INVALID_PARAMETER",
    "failMsg": "One or more input parameters are invalid.",
    "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": "std-text-to-video",
    "prompt": "a cinematic city skyline at sunset",
    "duration": 5,
    "sound": false,
    "aspect_ratio": "16:9"
  }
}
```

### 專業影像轉影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "pro-image-to-video",
    "prompt": "animate the subject walking toward the camera",
    "duration": 10,
    "sound": true,
    "image_urls": [
      "https://example.com/start.png",
      "https://example.com/end.png"
    ]
  }
}
```

### 帶有參考影片的參考影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "std-reference-to-video",
    "prompt": "keep the same visual style and motion mood",
    "duration": 6,
    "sound": true,
    "aspect_ratio": "16:9",
    "image_urls": [
      "https://example.com/ref-1.png",
      "https://example.com/ref-2.png"
    ],
    "video_urls": [
      "https://example.com/reference.mp4"
    ]
  }
}
```

### 4K 影片參考

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "4k-reference-to-video",
    "prompt": "turn these product reference images into a polished 4K product video",
    "duration": 8,
    "sound": true,
    "aspect_ratio": "16:9",
    "image_urls": [
      "https://example.com/ref-1.png",
      "https://example.com/ref-2.png"
    ]
  }
}
```

## 參數

**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*

Kling 3.0 Omni 的輸入參數。

**屬性**

**mode** `string` *required*

生成模式。可用值為 `std-text-to-video`、`std-image-to-video`、`std-reference-to-video`、`pro-text-to-video`、`pro-image-to-video`、`pro-reference-to-video`、`4k-text-to-video`、`4k-image-to-video`、`4k-reference-to-video`。

**prompt** `string` *required*

描述所需影片的文字提示。APIXO 修剪空白並拒絕遺失、非字串或空提示。最大長度：2500 個字元。

**duration** `integer|string` (default: 5)

輸出持續時間（以秒為單位）。接受整數或整數字串。預設為 `5`。大多數模式支援 `3` 到 `15`；`pro-text-to-video` 和 `pro-image-to-video` 僅支援 `5` 或 `10`。

**sound** `boolean` (default: false)

是否產生或保留聲音。提供時必須是 JSON 布林值。對於使用 `video_urls` 的參考模式，`sound=true` 要求 APIXO 在支援的情況下保留參考影片中的原始聲音。

**aspect\_ratio** `string` (default: 16:9)

文字和參考模式的輸出寬高比。支援的值：`16:9`、`9:16`、`1:1`。影像模式忽略該欄位。

**shot\_type** `string`

可選擇的射擊行為。支援的值：`customize`、`intelligent`。

**multi\_prompt** `object[]`

可選提示段。提供 1-6 個物件。每個項目必須包含一個非空字串 `prompt` 和一個整數 `duration`。

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

影像 URL。若為含影像的模式，需提供 1-2 個影像。對於 `std-reference-to-video` 與 `pro-reference-to-video`，若未提供參考影片，則提供 1-7 個影像；若提供 `video_urls`，則提供 0-4 個影像。對於 `4k-reference-to-video`，提供 1-7 個影像。所有項目必須為非空字串。

**video\_urls** `string[]`

參考影片網址。僅 `std-reference-to-video` 與 `pro-reference-to-video` 支援。提供後，APIXO 會使用第一個非空 URL 並忽略其餘 URL。引用的檔案必須為 MP4 或 MOV，大小不超過 200 MB、長度為 3-15 秒，且每邊解析度介於 700 至 3840 像素之間。`4k-reference-to-video` 會忽略 `video_urls`。

## 模式行為

| 模式 | 所需媒體 | 長度 | 筆記 |
| - | - | - | - |
| `std-text-to-video` | 沒有任何設定 | `3-15`，預設為 `5` | 使用 `aspect_ratio` 與 `sound` |
| `std-image-to-video` | 1-2 `image_urls` | `3-15`，預設為 `5` | 第一張影像為起始影格；第二張影像為可選的結束影格。 |
| `std-reference-to-video` | 1-7 張影像，或第一個 `video_urls` 項，最多包含 4 張影像 | `3-15`，預設為 `5` | 使用 `aspect_ratio`；參考影片定價與僅影像參考模式不同。 |
| `pro-text-to-video` | 沒有任何設定 | `5`或`10`，預設`5` | 使用 `aspect_ratio` 與 `sound` |
| `pro-image-to-video` | 1-2 `image_urls` | `5`或`10`，預設`5` | 第一張影像為起始影格；第二張影像為可選的結束影格。 |
| `pro-reference-to-video` | 1-7 張影像，或第一個 `video_urls` 項，最多包含 4 張影像 | `3-15`，預設為 `5` | 使用專業參考定價。 |
| `4k-text-to-video` | 沒有任何設定 | `3-15`，預設為 `5` | 4K 每秒速率； `sound` 不改變價格。 |
| `4k-image-to-video` | 1-2 `image_urls` | `3-15`，預設為 `5` | 4K 每秒速率。 |
| `4k-reference-to-video` | 1-7 `image_urls` | `3-15`，預設為 `5` | 忽略`video_urls`； 4K 每秒速率。 |

> [!TIP]
>
> 使用直接且公開可存取的媒體 URL。對於影像模式，請精確提供您希望用作起始影格與可選結束影格的影像。

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/kling-3-0-omni` 會傳回任務 ID：

**code** `integer`

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

**message** `string`

狀態說明。

**data.taskId** `string`

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

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

目前的任務狀態，可能的值為 `pending`、`processing`、`processing_r2`、`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/kling-3-0-omni" \
  -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 the product photo with a slow cinematic camera move",
      "duration": 10,
      "sound": true,
      "image_urls": [
        "https://example.com/product.png"
      ]
    }
  }'
```

回呼有效負載使用與狀態回應相同的 `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)。

Kling 3.0 Omni 按輸出秒數計費。總成本為：

```text theme={null}
total cost = duration * selected mode unit price
```

| 模式群組 | 條件 | 單價 |
| - | - | - |
| `std-text-to-video`, `std-image-to-video` | `sound=false` | `$0.084 / second` |
| `std-text-to-video`, `std-image-to-video` | `sound=true` | `$0.112 / second` |
| `std-reference-to-video` | 無 `video_urls`、`sound=false` | `$0.084 / second` |
| `std-reference-to-video` | 無 `video_urls`、`sound=true` | `$0.112 / second` |
| `std-reference-to-video` | 有 `video_urls` | `$0.126 / second` |
| `pro-text-to-video`, `pro-image-to-video` | `sound=false` | `$0.112 / second` |
| `pro-text-to-video`, `pro-image-to-video` | `sound=true` | `$0.14 / second` |
| `pro-reference-to-video` | 無 `video_urls`、`sound=false` | `$0.112 / second` |
| `pro-reference-to-video` | 無 `video_urls`、`sound=true` | `$0.140 / second` |
| `pro-reference-to-video` | 有 `video_urls` | `$0.168 / second` |
| `4k-text-to-video`, `4k-image-to-video`, `4k-reference-to-video` | 固定 4K 速率 | `$0.42 / second` |

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

## 耗時與輪詢

Kling 3.0 Omni 任務是異步的。實際延遲會因模式、提示複雜性、媒體輸入、持續時間、4K 選擇、路由佇列負載和產生時間而異。

| 工作量 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| 標準文字/影像剪輯 | 60s-120s | 任務建立 60 秒後 | 5s-10s |
| 專業或參考引導剪輯 | 90s-180s | 任務建立 60 至 90 秒後 | 5s-10s |
| 4K 剪輯 | 通常比標準生成模式耗時更長 | 任務建立 90 秒後 | 10s-15s |

> [!TIP]
>
> 正式環境建議使用回呼，以免在影片生成期間頻繁輪詢。

結果連結有時效。任務完成後，請盡快下載並儲存重要檔案。

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

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、缺少 `input`、不受支援的 `mode`、媒體陣列無效、持續時間不受支援或可選欄位無效 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `404` | 輪詢時未找到任務 | 檢查`taskId` |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤或未知任務失敗 | 逐步拉長間隔後重試 |
| `502` | 服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 服務超時 | 稍後重試或對長時間運行的作業使用回呼模式 |

### 驗證說明

| 條件 | 後端行為 |
| - | - |
| 缺失或不受支持 `mode` | 請求會遭拒，系統不會建立任務。 |
| 缺失、非字串或空 `prompt` | 請求會遭拒，系統不會建立任務。 |
| 缺少 `duration` | 預設值為 `5`。 |
| `duration` 在 `3-15` 之外 | 請求會遭拒，系統不會建立任務。 |
| `pro-text-to-video` 或 `pro-image-to-video` 持續時間（除 `5` 或 `10`） | 請求會遭拒，系統不會建立任務。 |
| `sound` 不是布林值 | 請求會遭拒，系統不會建立任務。 |
| 不支援的 `aspect_ratio` 值 | 任務創建之前請求失敗。使用`16:9`、`9:16`或`1:1`。 |
| 無`image_urls`的影像模式 | 請求會遭拒，系統不會建立任務。 |
| 圖片模式下，`image_urls` 超過 2 個 | 請求會遭拒，系統不會建立任務。 |
| 不含 `image_urls` 或 `video_urls` 的參考模式 | 請求在建立任務之前失敗，不使用引用的文字/影像模式除外。 |
| 參考模式下指定了 `video_urls`，並且圖片超過 4 張 | 請求會遭拒，系統不會建立任務。 |
| `4k-reference-to-video` 無 `image_urls` | 請求會遭拒，系統不會建立任務。 |
| `shot_type` 不是 `customize` 或 `intelligent` | 請求會遭拒，系統不會建立任務。 |
| `multi_prompt` 超過 6 項，或其中有無效的物件 | 請求會遭拒，系統不會建立任務。 |

### 任務失敗代碼

`failCode` 表示任務失敗的原因，常見值如下。

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `CONTENT_VIOLATION` | 提示或輸入/輸出內容被安全檢查拒絕 | 更改提示或輸入媒體 |
| `INVALID_PARAMETER` | 缺少必填欄位或值不受支援 | 檢查`mode`、`duration`、`sound`、`image_urls`、`video_urls`和`aspect_ratio` |
| `INVALID_IMAGE_URL` | 無法取得或解碼參考影像 | 使用直接、可公開存取的影像 URL |
| `INVALID_VIDEO_URL` | 無法取得或解碼參考影片 | 使用直接、可公開存取的影片 URL |
| `INSUFFICIENT_BALANCE` | 該帳戶沒有足夠的餘額來執行任務 | 重試前加結餘額 |
| `UPSTREAM_ERROR` | 服務無法完成任務 | 逐步拉長間隔後重試 |
| `UNKNOWN_ERROR` | 任務因不明原因失敗 | 稍後重試或透過 `taskId` 聯繫支援人員 |

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

## MCP 整合

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


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