> ## 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 Standard API：文字生成影片與圖片生成影片

> 標準品質影片生成 API，具有文字到影片、影像到影片和運動控制模式

## 概覽

Kling 3.0 Std 用於生成標準畫質的影片。可以用文字提示詞生成影片、讓參考圖動起來，或把參考影片裡的動作遷移到新影片中。在 APIXO Playground 試用後，可依本頁範例呼叫 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `kling-3-0-std` |
| 模式 | `text-to-video`, `image-to-video`, `motion-control` |
| 文字提示 | `text-to-video` 和 `image-to-video` 需要；`motion-control` 可選 |
| 參考圖片 | `image-to-video`：1-2 URL；`motion-control`：剛好1 URL |
| 參考影片 | `motion-control`：剛好是 1 公共 MP4、MOV 或 M4V URL |
| 長度 | `text-to-video`和`image-to-video`：3-15秒，預設`5` |
| 體控持續時間 | 從`video_urls[0]`自動偵測；超過 30 秒的影片將被拒絕 |
| 縱橫比 | `1:1`、`9:16`、`16:9` 對應 `text-to-video` |

## 端點與身分驗證

API 基底網址：

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

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

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines",
    "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": "text-to-video",
    "prompt": "a cinematic city skyline at sunset, slow camera push-in",
    "negative_prompt": "blur, low quality",
    "duration": 5,
    "sound": false,
    "aspect_ratio": "16:9",
    "cfg_scale": 0.5,
    "multi_prompt": [
      {
        "duration": 2,
        "prompt": "wide establishing shot"
      },
      {
        "duration": 3,
        "prompt": "slow push-in toward glowing skyscrapers"
      }
    ]
  }
}
```

### 圖生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "animate the character waving to the camera",
    "duration": 6,
    "sound": true,
    "image_urls": [
      "https://example.com/start.png",
      "https://example.com/end.png"
    ],
    "cfg_scale": 0.5
  }
}
```

### 運動控制

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "motion-control",
    "prompt": "keep the same character identity while following the motion reference",
    "negative_prompt": "distorted face, extra limbs",
    "sound": true,
    "character_orientation": "video",
    "image_urls": [
      "https://example.com/character.png"
    ],
    "video_urls": [
      "https://example.com/motion.mp4"
    ]
  }
}
```

## 參數

**request\_type** `string` *required* (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 Std 的輸入參數。

**屬性**

**mode** `string` *required*

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

**prompt** `string`

影片的文字提示。`text-to-video` 和 `image-to-video` 需要；`motion-control` 可選。如果提供，它必須是非空字串。最大長度：2500 個字元。

**negative\_prompt** `string`

選填的否定提示。如果提供，它必須是非空字串。最大長度：2500 個字元。

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

`text-to-video` 和 `image-to-video` 的輸出持續時間（以秒為單位）。支援從 `3` 到 `15` 的整數值或數字字串。在 `motion-control` 中被忽略且未轉發。

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

對於 `text-to-video` 和 `image-to-video`，控制 Kling 是否隨影片產生音訊。對於 `motion-control`，控制是否保留參考影片的原始音訊。

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

僅輸出 `text-to-video` 的縱橫比。支援的值：`1:1`、`9:16`、`16:9`。

**cfg\_scale** `number`

`text-to-video` 和 `image-to-video` 的指導比例。支援的範圍：`0` 至 `1`。

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

參考影像 URL。對於 `image-to-video` 與 `motion-control` 是必需的。 `image-to-video` 支援 1-2 張圖片； `motion-control` 剛好需要 1 張影像。使用 JPG、JPEG 或 PNG 影像，每張影像不得超過 10 MB。

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

僅 `motion-control` 需要。準確提供 1 公開 HTTP/HTTPS MP4、MOV 或 M4V URL。APIXO 探測 `video_urls[0]` 以檢測持續時間；超過 30 秒的影片將被拒絕。

**character\_orientation** `string`

僅 `motion-control`。支援的值：`image`、`video`。確定角色方向是遵循角色影像還是運動參考影片。

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

`text-to-video` 和 `image-to-video` 的可選鏡頭級提示段。每個項目必須包含一個非空 `prompt` 和一個 `duration` 整數或數字字串。`multi_prompt` 不影響計費。每個項目的 `prompt` 的最大長度為 2500 個字元。

## 回應格式

### 送出任務時的回應

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

**code** `integer`

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

**message** `string`

狀態說明。

**data.taskId** `string`

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

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

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

**resultJson** `string`

內含生成影片 URL 的 JSON 字串。`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/kling-3-0-std" \
  -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",
      "prompt": "animate the product photo with a slow studio camera move",
      "duration": 5,
      "sound": true,
      "image_urls": [
        "https://example.com/product.png"
      ]
    }
  }'
```

Webhook 的接收條件與重試規則請見 [Webhook 文件](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 Std 依產生的影片秒數計費。對於`text-to-video`和`image-to-video`，所選的`sound`值決定單價。對於 `motion-control`，APIXO 探測參考影片持續時間並使用至少 3 的計費秒數。

| 工作流程 | 計費輸入 | APIXO 價格 |
| - | - | - |
| `text-to-video`或`image-to-video`、`sound: false` | `duration`秒 | `$0.084 / second` |
| `text-to-video`或`image-to-video`、`sound: true` | `duration`秒 | `$0.13 / second` |
| `motion-control` | 偵測到 `video_urls[0]` 持續時間，最短 3 秒 | `$0.13 / second` |

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

## 耗時與輪詢

實際延遲可能會因提示複雜性、參考媒體、聲音產生、路由和目前佇列負載而異。

| 請求結構 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| 3-5 秒影片（由文字或圖片生成） | 60s-90s | 任務建立 60 秒後 | 5s-10s |
| 6-10 秒影片（由文字或圖片生成） | 90s-120s | 任務建立 60 秒後 | 5s-10s |
| 11-15 秒影片（由文字或圖片生成） | 120s-180s | 任務建立 60 秒後 | 5s-10s |
| 運動控制 | 隨參考影片時長和探測而變化 | 任務建立 60 秒後 | 5s-10s |

> [!TIP]
>
> 影片生成比影像生成花費更長的時間。對於生產工作負載，請使用回呼模式以避免頻繁輪詢。

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

## 錯誤與排查

### HTTP 錯誤

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

### 任務失敗代碼

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `CONTENT_VIOLATION` | 提示或參考介質未通過安全性檢查 | 更改提示或輸入媒體 |
| `INVALID_IMAGE_URL` | 無法取得或解碼參考影像 URL | 使用公共直接 JPG、JPEG 或 PNG URL |
| `INVALID_VIDEO_URL` | 無法取得、解碼或探測參考影片 URL | 使用公共MP4、MOV或M4V URL |
| `INVALID_PARAMETER` | 模型參數不受支援或格式錯誤 | 檢查`mode`、`duration`、`sound`、`aspect_ratio`、`image_urls`和`video_urls` |
| `INSUFFICIENT_BALANCE` | 該帳戶沒有足夠的餘額來執行任務 | 重試前加結餘額 |
| `UPSTREAM_ERROR` | 服務無法完成任務 | 逐步拉長間隔後重試 |
| `TIMEOUT` | 生成任務逾時 | 重試、簡化輸入或使用回呼模式 |

### 常見修復

| 問題現象 | 處理方式 |
| - | - |
| 請求因模式無效而失敗 | 將`input.mode`設定為`text-to-video`、`image-to-video`或`motion-control` |
| 意外的音訊費用 | `sound`預設為`true`；設定 `sound: false` 為不產生音訊的文字/影像影片 |
| `duration`對運動控制沒有影響 | 此模式可偵測從`video_urls[0]`開始的持續時間，且不轉發`duration` |
| 縱橫比沒有影響 | `aspect_ratio` 僅轉發給 `text-to-video` |
| 影片 URL 探頭失敗 | 使用支援範圍讀取或完整下載的直接公開 HTTP/HTTPS MP4、MOV 或 M4V URL |
| 運動控制影片被拒絕 | 將參考影片保持在 30 秒或更短的時間 |

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

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/kling-3-0-std.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 Std](https://apixo.ai/models/kling-3-0-std)
* [API定價](https://apixo.ai/pricing/api)


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