> ## 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 2.5 Turbo Pro API：快速生成高质量视频

> 通过文生视频、图生视频和尾帧控制快速生成高质量视频

## 概览

要结束特定构图的拍摄，请选择 `image-to-video`，并将开头图像置于 `image_urls` 的第一位，将所需最终帧置于第二位。对于仅包含起始帧的动画，发送一个 URL。剪辑长度设置为 `5` 或 `10` 秒，详见 [图生视频请求](#image-to-video)。

| 功能 | 值 |
| - | - |
| 模型 ID | `kling-2-5-turbo-pro` |
| 模式 | `text-to-video`, `image-to-video` |
| 提示词长度 | 1 至 2500 个字符 |
| 时长 | `5` 或 `10` 秒 |
| 参考图片 | 支持 1-2 个 `image-to-video` 的 URL |
| 尾帧控制 | `image_urls` 的第二个项将被用作最终帧 |
| 纵横比 | `16:9`、`9:16`、`1:1` 适用于 `text-to-video` |
| 负面提示 | 最多 2500 个字符 |
| CFG 缩放 | `0` 至 `1`，步长 `0.1` |
| 输出 | MP4 视频网址位于 `resultJson.resultUrls` |

## 接口与身份验证

API 基础地址：

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

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/kling-2-5-turbo-pro` | 提交生成任务 |
| `GET` | `/statusTask/kling-2-5-turbo-pro?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-2-5-turbo-pro" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic drone shot over snowy mountains at sunrise",
      "duration": 5,
      "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-2-5-turbo-pro?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/xxx.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content was rejected by safety checks, 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": "text-to-video",
    "prompt": "a cinematic drone shot over snowy mountains at sunrise",
    "duration": 10,
    "aspect_ratio": "16:9",
    "negative_prompt": "low quality, jitter, blur",
    "cfg_scale": 0.6
  }
}
```

### 图生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "smooth camera transition from the first frame to the final frame",
    "duration": 5,
    "image_urls": [
      "https://example.com/start.jpg",
      "https://example.com/end.jpg"
    ],
    "negative_prompt": "distortion, low quality",
    "cfg_scale": 0.4
  }
}
```

## 参数

**request\_type** `string` *required* (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 2.5 Turbo Pro 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-video`、`image-to-video`。

**prompt** `string` *required*

描述视频的文字提示。修剪后必须非空且长度不能超过 2500 个字符。

**duration** `integer | string` *required*

输出持续时间（以秒为单位）。支持的值：`5`、`10`。也接受 `"5"` 等数字字符串。

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

`image-to-video` 所需。支持 1-2 可公开访问的图像 URL。第一个图像是起始帧；第二张图片（如果提供）是尾框。每张图像必须为 JPG、JPEG 或 PNG，不大于 10 MB，每边至少 300 个像素，并且宽高比为 0.4 到 2.5。

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

`text-to-video` 的输出纵横比。支持的值：`16:9`、`9:16`、`1:1`。不会为 `image-to-video` 转发此字段。

**negative\_prompt** `string`

描述要避免的内容的负面提示。最多支持 2500 个字符。空白值将被忽略。

**cfg\_scale** `number | string`

提示引导强度。支持的值为 `0` 到 `1`，步长为 `0.1`，例如 `0`、`0.4`、`0.7` 或 `1`。接受数字字符串。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/kling-2-5-turbo-pro` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`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/kling-2-5-turbo-pro" \
  -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": "make the subject turn toward camera with smooth natural motion",
      "duration": 5,
      "image_urls": [
        "https://example.com/start.jpg"
      ],
      "cfg_scale": 0.5
    }
  }'
```

Webhook 交付使用与状态响应相同的最终任务负载形状。请参阅 [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 2.5 Turbo Pro 按视频时长计费。公开 APIXO 定价页面列出了此型号，起始 APIXO 价格为 `$0.06 / second`。

| 时长 | APIXO 起售价 |
| - | - |
| `5`秒 | `$0.30 / video` |
| `10`秒 | `$0.60 / video` |

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

实际延迟可能因提示复杂度、输入图像、所选路径及当前队列负载而有所不同。

| 时长 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `5`秒 | 30s-45s | 任务创建 30 秒后 | 5s-10s |
| `10`秒 | 45s-60s | 任务创建 30 秒后 | 5s-10s |

> [!TIP]
>
> 对于生产环境的视频工作负载，请使用回调模式以避免频繁轮询。任务完成後应立即下载并保存关键输出 URL。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、参数值或图像 URL 格式无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无法访问模型，或者内容被拒绝 | 检查权限并调整输入 |
| `404` | 未找到任务 ID 或路由 | 检查模型端点和`taskId` |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知任务失败 | 逐步延长间隔后重试 |
| `503` | 服务暂时不可用 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试；耗时较长的任务可改用回调模式 |

### 参数验证

| 字段 | 规则 |
| - | - |
| `input.mode` | 必填。必须使用以下值之一：`text-to-video`、`image-to-video`。 |
| `input.prompt` | 必填字符串，修剪后非空，最多 2500 个字符。 |
| `input.duration` | 必需的。必须是`5`或`10`；接受整数和数字字符串。 |
| `input.image_urls` | `image-to-video` 所需；必须是 1-2 字符串数组。 |
| `input.aspect_ratio` | `text-to-video` 可选；如果提供的话，必须是 `16:9`、`9:16` 或 `1:1`。 |
| `input.negative_prompt` | 可选字符串，最多 2500 个字符。 |
| `input.cfg_scale` | 从 `0` 到 `1` 的可选数字或数字字符串，步骤 `0.1`。 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `SensitiveContent` | 提示、输入图像或生成的输出违反内容安全要求 | 更改提示或图像 |
| `PromptInvalid` | 提示被拒绝或格式错误 | 用更清晰的安全内容重写提示 |
| `PromptLengthExceeded` | 提示超出模型限制 | 缩短提示 |
| `ImageFormatIncorrect` | 无法处理输入图像格式 | 使用公共 JPG、PNG 或 WebP URL |
| `Upload error` | 图片上传失败或超出大小限制 | 压缩图像并直接使用 URL 重试 |
| `RateLimited` | 请求频率达到上限 | 稍后重试并退避 |
| `Timeout` | 任务超时 | 重试、降低输入复杂度或使用回调模式 |
| `Unknown error` | 任务因未知原因失败 | 重试并退避；如果问题仍然存在，请联系支持人员 |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/kling-2-5-turbo-pro.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_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 2.5 Turbo Pro](https://apixo.ai/models/kling-2-5-turbo-pro)
* [API定价](https://apixo.ai/pricing/api)


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