> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixroute.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling 图生视频

> Kling 首帧、首尾帧、Element 与音色输入参数。

使用 MixRoute API Key，以 `Authorization: Bearer $MIXROUTE_API_KEY` 认证，请求体为 JSON。模型 ID 位于 URL 中，不在请求体中重复传 `model`；不添加 `/v1`，也不使用 `metadata` 包装。

## 支持模型

| 模型 ID | 分辨率 | 普通生成时长（秒） |
| - | - | - |
| [kling-3.0](/zh-hans/model-api/kuaishou/kling-3.0) | 720p / 1080p / 4k | 3-15 |
| [kling-3.0-turbo](/zh-hans/model-api/kuaishou/kling-3.0-turbo) | 720p / 1080p | 3-15 |
| [kling-2.6](/zh-hans/model-api/kuaishou/kling-2.6) | 720p / 1080p | 5 / 10 |
| [kling-2.5-turbo](/zh-hans/model-api/kuaishou/kling-2.5-turbo) | 720p / 1080p | 5 / 10 |

## 素材内容

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `contents` | object\[] | 是 | 输入集合。必须提供首帧，不支持只传尾帧；各项 type 与附属字段放在同一对象。 |
| `contents[].type` | string | 是 | 每项必填。prompt、first\_frame；last\_frame 适用于 3.0/2.6/2.5 Turbo；element 仅 3.0；voice 仅 2.6。 |
| `contents[].text` | string | 按类型 | prompt 项必填。3.0 最多 3072 字符（建议 2500）；其他型号最多 2500。 |
| `contents[].url` | string | 按类型 | first\_frame/last\_frame 项必填，公网图片 URL 或 Base64。 |
| `contents[].element_id` | string | 按类型 | element 项必填，3.0 最多引用 3 个 Element。 |
| `contents[].voice_id` | string | 按类型 | voice 项必填，2.6 最多引用 2 个音色，须使用 audio=native 与 1080p。 |
| `contents[].id` | string | 按类型 | element/voice 项必填，同任务不可重复，用 @id 在提示词中引用。 |

## 生成设置

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `settings.resolution` | string | 否 | 默认 720p。3.0 可用 720p/1080p/4k，其他型号仅 720p/1080p。2.6/2.5 Turbo 首尾帧模式必须 1080p。 |
| `settings.duration` | integer | 否 | 默认 5。3.0/3.0 Turbo 为 3-15；2.6/2.5 Turbo 仅 5 或 10。 |
| `settings.audio` | string | 否 | 3.0/2.6 支持 off（默认）或 native。2.6 原生音频只支持 1080p。3.0 Turbo 和 2.5 Turbo 不传此字段。 |
| `settings.multi_shot` | boolean | 否 | 仅 3.0，默认 true。false 时多镜头提示词不产生多镜头输出。 |

普通图生端点不提供 `aspect_ratio`，画幅跟随输入图像。3.0 Turbo 仅首帧，不支持尾帧、Element 或音色引用。3.0 使用 Element 时在提示词中写 `@id`，名称不要互相包含；其分镜提示词规则与文生视频一致。

## 图片限制

JPG/JPEG/PNG，单张不超过 50 MB，宽和高均至少 300 px，宽高比介于 1:2.5 和 2.5:1。使用首帧或首帧+尾帧；不要只传尾帧。资产 ID 的可访问性取决于上游路由账户。

## 请求示例

先设置环境变量 `MIXROUTE_API_KEY`。将 `example.com` 媒体地址替换为无需登录即可访问的真实素材。

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/image-to-video/kling-3.0" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "type": "prompt",
      "text": "A closed gift box slowly opens to reveal a ceramic mug."
    },
    {
      "type": "first_frame",
      "url": "https://example.com/first.png"
    },
    {
      "type": "last_frame",
      "url": "https://example.com/last.png"
    }
  ],
  "settings": {
    "resolution": "1080p",
    "duration": 5,
    "audio": "native",
    "multi_shot": false
  }
}'
```

通用选项见 [Kling 概览](/zh-hans/api-reference/endpoint/kling)。

## 提交响应

```json theme={null}
{
  "code": 0,
  "message": "",
  "request_id": "REQUEST_ID",
  "data": {
    "id": "task_example",
    "status": "submitted"
  }
}
```

保存 `data.id`，使用 [查询 Kling 任务](/zh-hans/api-reference/endpoint/kling-tasks) 轮询至 `succeeded` 或 `failed`。提交成功不代表生成完成。


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