> ## 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/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/api-reference/webhooks.md)。

## 计费

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

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、参数、图像URL或视频URL无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `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` | 生成任务超时 | Retry、简化输入或使用回调模式 |

### 常见问题解决方法

| 问题表现 | 解决办法 |
| - | - |
| 请求因模式无效而失败 | 将`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/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/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 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.