> ## 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/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 张图像。所有图像 URL 必须为非空字符串。

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

参考视频 URL。仅 `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/api-reference/webhooks.md) 了解交付要求和重试行为。

## 计费

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

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体无效、缺少 `input`、不受支持的 `mode`、媒体数组无效、持续时间不受支持或可选字段无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `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/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/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 尝试 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.