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

# KLING 4.0 视频：线路与请求参数

> KLING 4.0 视频生成：渠道 MG 的模型名、清晰度写法、能力和统一请求写法

> [!NOTE]
>
> **给 AI 助手的要点**
>
> * 接口：`POST https://1788.love/v1/videos`，请求头 `Authorization: Bearer YOUR_1788_API_KEY`、`Content-Type: application/json`。创建 → 查询 → 下载见[任务式接口](https://docs.1788.love/guides/async-tasks.md)。
> * 目前只有渠道 MG 一条线路，两个模型名：`kling-mg-720` 和 `kling-mg-1080`。**清晰度写在模型名里**：要 720p 用 `kling-mg-720`，要 1080p 用 `kling-mg-1080`。`resolution` 不用填；填了和模型名不一致的值会报错。
> * 素材写成 `image_with_roles` / `video_with_roles`（**不支持参考音频**），和 [Seedance](https://docs.1788.love/video/seedance/request.md) 一致；也接受 `image_urls` / `video_urls` / `audio_urls`。比例写 `aspect_ratio`（也接受 `ratio`）。`duration` 是 JSON 数字。
> * **带参考视频必须写 `reference_video_duration`**（所有参考视频的总秒数，整数，1–150）。计费按"参考视频秒数 + 成片秒数"。
> * 不支持尾帧；不支持的素材、超量会直接报错，不会悄悄忽略。价格见[价目表](https://1788.love/pricing)。

## 线路表

| 模型名 | 渠道 | 计费 | 清晰度 | 时长（秒） | 比例 | 图 / 视频 / 音频上限 | 首帧 / 尾帧 |
| - | - | - | - | - | - | - | - |
| `kling-mg-720` | MG | 按秒 | 720p（模型名决定） | 3–30 | `16:9` `9:16` `1:1` `4:3` `3:4` `21:9` | 10 / 5 / **0** | 首帧 ✓（作为参考图）/ 尾帧 ✗ |
| `kling-mg-1080` | MG | 按秒 | 1080p（模型名决定） | 3–30 | 同上 | 10 / 5 / **0** | 同上 |

计费：按秒。带参考视频时，参考视频的秒数也一起计费（参考秒 + 成片秒），1080p 单价高于 720p。

## 统一请求写法

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `model` | string | 是 | `kling-mg-720` 或 `kling-mg-1080` |
| `prompt` | string | 是 | 画面描述；用"图1、视频1、音频1"指代素材，编号按数组顺序 |
| `duration` | integer | 建议 | 3–30 的整数秒，JSON 数字 |
| `aspect_ratio` | string | 建议 | 见线路表；也接受字段名 `ratio` |
| `resolution` | string | 否 | 不用填；填了必须和模型名里的清晰度一致 |
| `image_with_roles` | object\[] | 否 | `role` 取 `first_frame` 或 `reference_image`（默认）；`last_frame` 会报错 |
| `video_with_roles` | object\[] | 否 | 参考视频，`role` 固定 `reference_video` |
| `audio_with_roles` | object\[] | 否 | 不支持，带了报错 |
| `reference_video_duration` | integer | 带参考视频时必填 | 所有参考视频的总秒数，1–150 |

素材 URL 必须是公网 HTTP(S) 地址，不支持 base64。本地文件先用[上传素材](https://docs.1788.love/api-reference/upload-image.md)换成 URL。

## 会报的错

错误在**创建任务时**立即返回，任务不会创建，也不扣费。

| 错误信息（节选） | 原因 | 处理 |
| - | - | - |
| `duration must be an integer between 3 and 30 seconds` | 时长超出范围 | 取 3–30 的整数，用 JSON 数字 |
| `... resolution is fixed at 720p by the model name` | `resolution` 和模型名不一致 | 去掉 `resolution`，或换成对应清晰度的模型名 |
| `supports at most 10 images, 5 videos and 0 audios` | 素材数量超出上限 | 按线路表删减 |
| `requires reference_video_duration between 1 and 150 seconds when reference videos are used` | 带了参考视频但没填总秒数 | 填 1–150 的整数 |
| `does not support last_frame; use first_frame or reference_image` | 带了尾帧 | 改用参考图 |

## 示例

### 文生视频（720p）

```bash theme={null}
curl https://1788.love/v1/videos \
  -H "Authorization: Bearer YOUR_1788_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-mg-720",
    "prompt": "夜晚的城市天台，镜头环绕一位正在弹吉他的女孩",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'
```

### 多模态参考（1080p）

```json theme={null}
{
  "model": "kling-mg-1080",
  "prompt": "图1的人物按视频1的动作起舞",
  "duration": 8,
  "aspect_ratio": "9:16",
  "image_with_roles": [
    { "url": "https://ruyi6.cn/r/EXAMPLE_A.png", "role": "reference_image" }
  ],
  "video_with_roles": [
    { "url": "https://ruyi6.cn/r/EXAMPLE_C.mp4", "role": "reference_video" }
  ],
  "reference_video_duration": 6
}
```

创建成功后保存返回的 `id`，查询、下载见[任务式接口](https://docs.1788.love/guides/async-tasks.md)。


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