> ## 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 Omni 生成与编辑

> Kling 3.0 Omni 与 O1 的图片参考、视频参考和视频编辑。

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

## 支持模型

| 模型 ID                                                   | 分辨率               | 普通生成时长（秒） |
| ------------------------------------------------------- | ----------------- | --------- |
| [kling-3.0-omni](/cn/model-api/kuaishou/kling-3.0-omni) | 720p / 1080p / 4k | 3-15      |
| [kling-o1](/cn/model-api/kuaishou/kling-o1)             | 720p / 1080p      | 3-10      |

## 素材内容

| 字段                      | 类型        | 必填  | 说明                                                                                      |
| ----------------------- | --------- | --- | --------------------------------------------------------------------------------------- |
| `contents`              | object\[] | 是   | 文本及多模态输入集合。可仅包含 prompt 进行文本生成。                                                          |
| `contents[].type`       | string    | 是   | 每项必填：prompt、first\_frame、last\_frame、refer\_image、feature\_video、base\_video 或 element。 |
| `contents[].text`       | string    | 按类型 | prompt 项必填。3.0 Omni 最多 3072 字符（建议 2500）；O1 最多 2500。使用 @image\_1、@video\_1 等引用对应 id。     |
| `contents[].url`        | string    | 按类型 | 图像/视频项必填。图片支持 URL 或 Base64；视频使用公网 URL。feature\_video 用于特征参考，base\_video 用于编辑底片。         |
| `contents[].element_id` | string    | 按类型 | element 项必填，必须是上游路由账户可访问的资产。                                                            |
| `contents[].id`         | string    | 按类型 | element 项必填；图像/视频项可选，需要在提示词中引用时设置。同任务不能重复。                                              |

## 生成设置

| 字段                      | 类型      | 必填  | 说明                                                                                                 |
| ----------------------- | ------- | --- | -------------------------------------------------------------------------------------------------- |
| `settings.resolution`   | string  | 否   | 默认 720p。3.0 Omni：720p/1080p/4k；O1：720p/1080p。                                                      |
| `settings.duration`     | integer | 否   | 默认 5。3.0 Omni：3-15；O1：3-10。O1 仅首帧且无 refer\_image/视频参考时只能 5 或 10 秒。                                 |
| `settings.aspect_ratio` | string  | 按场景 | 16:9（默认）、9:16 或 1:1；没有首帧和视频参考时须明确提供。                                                               |
| `settings.audio`        | string  | 否   | 默认 off。3.0 Omni：native/original/off；O1：original/off。original 保留参考视频原声；有视频输入时 3.0 Omni 不能使用 native。 |
| `settings.multi_shot`   | boolean | 否   | 仅 3.0 Omni，默认 true。feature\_video 场景须 true；base\_video 编辑不支持多镜头，设 false。O1 不传。                     |

## 输入组合

* 两个型号都最多输入一个视频；`base_video` 编辑不能搭配首帧或尾帧。
* 首尾帧必须成对或仅首帧，不支持仅尾帧。O1 首尾帧模式不能加参考图或 Element；O1 的 `feature_video` 可搭配首帧，但不能尾帧。
* O1 仅支持多图 Element：无视频时，参考图片与 Element 合计最多 7 个；有视频时最多 4 个。
* 3.0 Omni 无视频且仅使用多图 Element 时，参考图片与多图 Element 合计最多 7 个；加入视频角色 Element 时，视频角色最多 3 个，参考图片与多图 Element 合计最多 4 个。
* 3.0 Omni 有视频时，可加最多 4 个参考图片/多图 Element，或最多 1 个视频角色 Element；不能同时搭配视频角色与参考图片/多图 Element。首帧/首尾帧生成最多 3 个 Element。
* 3.0 Omni 使用 `feature_video` 时只允许 `audio=off`；使用 `base_video` 时选择 `off` 或 `original`。无视频输入时才可使用 `native`。

## 媒体限制

| 素材          | 限制                                                                             |
| ----------- | ------------------------------------------------------------------------------ |
| 图片          | JPG/JPEG/PNG，最多 50 MB；宽高均至少 300 px，宽高比 1:2.5 至 2.5:1。                          |
| 3.0 Omni 视频 | MP4/MOV，最多 200 MB，3-15.5 秒；宽高各 700-4553 px，总像素不超过 8294400；宽高比 0.4-2，24-60 fps。 |
| O1 视频       | MP4/MOV，最多 200 MB，3-10 秒；宽高各 700-2160 px，24-60 fps。                            |

## 分镜提示词

仅 3.0 Omni 支持多镜头生成。开启 `settings.multi_shot` 后，使用 `shot n, m, words;` 格式，以英文分号分隔：1-6 个镜头，每镜至少 1 秒，所有镜头时长之和等于 `settings.duration`，每镜提示词最多 512 字符。`base_video` 编辑不支持该模式；不要将多镜头参数传给 O1。素材引用名须唯一，避免名称互相包含或与提示词中的其他文字重叠。

## 图片参考示例

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

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/omni-video/kling-3.0-omni" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "type": "prompt",
      "text": "The mug in @image_1 slowly rotates on a white tabletop. Soft studio lighting."
    },
    {
      "type": "refer_image",
      "url": "https://example.com/reference.png",
      "id": "image_1"
    }
  ],
  "settings": {
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "audio": "native",
    "multi_shot": false
  }
}'
```

## O1 视频编辑示例

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/omni-video/kling-o1" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "type": "prompt",
      "text": "Change the red mug in @video_1 to blue. Preserve the original motion and background."
    },
    {
      "type": "base_video",
      "url": "https://example.com/source.mp4",
      "id": "video_1"
    }
  ],
  "settings": {
    "resolution": "720p",
    "duration": 5,
    "audio": "off"
  }
}'
```

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

## 提交响应

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

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