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

# Kling 4.0 Omni

> 可灵 Kling 4.0 Omni：多模态参考生视频与视频编辑，可同时参考最多 10 张图片、5 段视频和 3 段音频。

`kling-4.0-omni` 对应可灵 4.0 的全能参考（Omni Reference）能力：把图片、视频、音频等多种参考素材组合进同一次生成，让人物、场景和声音保持一致。除提示词外，可以同时参考最多 10 张图片、5 段视频和 3 段音频，一次生成 3 \~ 30 秒、音画同出的视频，也可以直接编辑已有视频。参考视频分为特征参考（`feature`）和待编辑视频（`base`）两种用法，并可选择保留参考视频的原声。只需要文生视频、首帧或首尾帧时，请使用 [Kling 4.0](https://docs.dreamto.ai/video/models/kling-4-0.md)。

* **多模态参考**：最多 10 张参考图、5 段参考视频（单段 3 \~ 30 秒、合计不超过 30 秒）和 3 段参考音频，可自由组合。
* **视频编辑**：把参考视频作为待编辑视频（`base`），按提示词修改画面。
* **特征参考**：把参考视频作为特征参考（`feature`）生成新视频。
* **保留原声**：`keep_original_sound` 控制是否保留参考视频的原声。
* **规格**：3 \~ 30 秒，720P / 1080P 原生输出，2K / 4K 超分输出，宽高比 16:9、9:16、1:1、21:9。

## 能力一览

| 模式 | 参数 | 说明 |
| - | - | - |
| 多图参考生视频 | `prompt` + `reference_image_urls` | 最多 10 张 |
| 视频特征参考 | `prompt` + `reference_video_urls`，`reference_video_type` 为 `feature` | 最多 5 段，单段 3 \~ 30 秒，合计不超过 30 秒 |
| 视频编辑 | `prompt` + `reference_video_urls`，`reference_video_type` 为 `base` | 可用 `keep_original_sound` 保留原声 |
| 音频参考 | 在以上请求中加入 `reference_audio_urls` | 最多 3 段 mp3 |

## 接口

接口为异步任务：创建任务后轮询查询，完成后从 `video_url` 下载视频。`model` 填 `kling-4.0-omni`，生成参数全部放在 `input` 中。

| 接口 | 用途 |
| - | - |
| [`POST /v1/videos`](https://docs.dreamto.ai/api-reference/kling-4-0-omni/create-task) | 创建视频生成任务 |
| [`GET /v1/videos/{task_id}`](https://docs.dreamto.ai/api-reference/kling-4-0-omni/query-task) | 查询视频生成任务 |

## 快速开始

创建任务拿到 `task_id`，每 10 \~ 15 秒查询一次，`status` 为 `completed` 时从 `video_url` 下载视频。示例中的 `$DREAMTO_API_KEY` 为你的 API Key。

```bash cURL theme={null}
# 1. 创建任务
curl -X POST "https://api.dreamto.ai/v1/videos" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0-omni",
    "input": {
      "prompt": "第一张图中的女孩和第二张图中的狐狸一起走在雪地森林里，电影感",
      "reference_image_urls": [
        "https://your-cdn.example.com/girl.png",
        "https://your-cdn.example.com/fox.png"
      ],
      "resolution": "1080P",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'

# 2. 查询任务
curl "https://api.dreamto.ai/v1/videos/job_02b88886c4fda5be35baff61" \
  -H "Authorization: Bearer $DREAMTO_API_KEY"
```

```python Python theme={null}
import os
import time

import requests

BASE_URL = "https://api.dreamto.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "kling-4.0-omni",
    "input": {
        "prompt": "第一张图中的女孩和第二张图中的狐狸一起走在雪地森林里，电影感",
        "reference_image_urls": [
            "https://your-cdn.example.com/girl.png",
            "https://your-cdn.example.com/fox.png"
        ],
        "resolution": "1080P",
        "duration": 5,
        "aspect_ratio": "16:9"
    }
}

task = requests.post(f"{BASE_URL}/v1/videos", headers=HEADERS, json=payload, timeout=60).json()
task_id = task["task_id"]
while task["status"] not in ("completed", "failed"):
    time.sleep(10)
    task = requests.get(f"{BASE_URL}/v1/videos/{task_id}", headers=HEADERS, timeout=60).json()
print(task["status"], task.get("video_url"), task.get("error"))
```

## 生成模式

### 多图参考生视频

传多张参考图，在提示词中说明每张图的用途。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/videos" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0-omni",
    "input": {
      "prompt": "第一张图中的女孩和第二张图中的狐狸一起走在雪地森林里，电影感",
      "reference_image_urls": [
        "https://your-cdn.example.com/girl.png",
        "https://your-cdn.example.com/fox.png"
      ],
      "resolution": "1080P",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'
```

### 参考图 + 参考音频

参考图加参考音频，21:9 超宽屏输出。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/videos" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0-omni",
    "input": {
      "prompt": "参考图中的女孩面对镜头说话，声音参考音频，背景是黄昏的海边",
      "reference_image_urls": [
        "https://your-cdn.example.com/girl.png"
      ],
      "reference_audio_urls": [
        "https://your-cdn.example.com/voice.mp3"
      ],
      "resolution": "720P",
      "duration": 5,
      "aspect_ratio": "21:9"
    }
  }'
```

### 视频特征参考

`reference_video_type` 为 `feature`：把视频作为特征参考生成新视频。带参考视频的请求按有参考视频的价格计费。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/videos" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0-omni",
    "input": {
      "prompt": "参考视频中的镜头运动，拍摄一辆红色跑车驶过沙漠公路",
      "reference_video_urls": [
        "https://your-cdn.example.com/reference.mp4"
      ],
      "reference_video_type": "feature",
      "resolution": "720P",
      "duration": 5
    }
  }'
```

### 视频编辑

`reference_video_type` 为 `base`：在原视频上按提示词修改，`keep_original_sound: true` 保留原声。

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/v1/videos" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0-omni",
    "input": {
      "prompt": "把视频中的季节从夏天改为下雪的冬天，人物和动作保持不变",
      "reference_video_urls": [
        "https://your-cdn.example.com/reference.mp4"
      ],
      "reference_video_type": "base",
      "keep_original_sound": true,
      "resolution": "720P",
      "duration": 5
    }
  }'
```

## 参数

以下参数都放在请求体的 `input` 中。

| 参数 | 类型 | 必填 | 默认值 | 取值 | 说明 |
| - | - | - | - | - | - |
| `prompt` | string | 是 | — | — | 提示词，必填。描述视频内容，并说明各个参考素材的用途。 |
| `reference_image_urls` | string\[] | 否 | — | 最多 10 个 | 参考图片的公网 URL 列表，最多 10 张。支持 jpeg / jpg / png，单张不超过 10MB。 |
| `reference_video_urls` | string\[] | 否 | — | 最多 5 个 | 参考视频的公网 URL 列表，最多 5 段。支持 mp4 / mov，单段 3 \~ 30 秒，合计不超过 30 秒。传入参考视频后按有参考视频的价格计费，计费时长为参考视频时长 + 输出时长（参考视频长于输出时）或输出时长 × 2。 |
| `reference_video_type` | string | 否 | — | `feature` / `base` | 参考视频的用法，仅在传入 `reference_video_urls` 时有效。 |
| `keep_original_sound` | boolean | 否 | — | `true` / `false` | 是否保留参考视频的原声，仅在传入 `reference_video_urls` 时有效。 |
| `reference_audio_urls` | string\[] | 否 | — | 最多 3 个 | 参考音频的公网 URL 列表，最多 3 段，支持 mp3。 |
| `resolution` | string | 否 | `720P` | `720P` / `1080P` / `2K` / `4K` | 输出分辨率，默认 `720P`。 |
| `duration` | integer | 否 | `5` | `3` \~ `30` | 输出视频时长，单位秒，`3` \~ `30` 的整数，默认 `5`。 |
| `aspect_ratio` | string | 否 | — | `16:9` / `9:16` / `1:1` / `21:9` | 输出宽高比。 |

完整的请求与响应定义见 [创建视频生成任务](https://docs.dreamto.ai/api-reference/kling-4-0-omni/create-task.md)。

## 响应与任务状态

创建任务返回 `task_id`、`status`、`model`、`created_at` 和 `request_id`。查询任务在此基础上返回 `completed_at`（任务结束后）、`video_url`（成功时）和 `error`（失败时）。

| `status` | 含义 |
| - | - |
| `queued` | 排队中。 |
| `in_progress` | 生成中。 |
| `completed` | 生成成功，从 `video_url` 下载视频。 |
| `failed` | 生成失败，原因见 `error`，不扣费。 |

生成成功的查询响应：

```json theme={null}
{
  "task_id": "job_02b88886c4fda5be35baff61",
  "status": "completed",
  "model": "kling-4.0-omni",
  "created_at": 1794846663,
  "completed_at": 1794847019,
  "request_id": "req_6a9a539502118ba1c33f1bfc",
  "video_url": "https://cdn.example.com/videos/02b88886c4fda5be35baff61.mp4"
}
```

生成失败的查询响应：

```json theme={null}
{
  "task_id": "job_02b88886c4fda5be35baff61",
  "status": "failed",
  "model": "kling-4.0-omni",
  "created_at": 1794846663,
  "completed_at": 1794847019,
  "request_id": "req_6a9a539502118ba1c33f1bfc",
  "error": {
    "type": "api_error",
    "message": "InvalidParameterValue: Please input the ImageURL that can be retrieved from the external network."
  }
}
```

## 计费

按计费时长（秒）× 所选分辨率的单价计费。未传参考视频时，计费时长为输出视频时长；传入参考视频时使用“有参考视频”的单价，计费时长为：参考视频时长大于输出时长时取“参考视频时长 + 输出时长”，否则取“输出时长 × 2”。

| 分辨率 | 无参考视频（每秒） | 有参考视频（每秒） |
| - | - | - |
| 720P | \$0.157 / ¥1.0 | \$0.0942 / ¥0.6 |
| 1080P | \$0.2355 / ¥1.5 | \$0.1413 / ¥0.9 |
| 2K | \$0.2826 / ¥1.8 | \$0.16956 / ¥1.08 |
| 4K | \$0.471 / ¥3.0 | \$0.471 / ¥3.0 |

以上为刊例价，实际价格以控制台显示的模型价格为准。生成失败的任务和参数错误的请求不扣费。

## 限制与注意事项

* `video_url` 自任务完成起 7 天内有效，请及时下载并保存到自己的存储。
* 输入素材必须是公网可直接下载的 URL；托管在海外的素材也可以使用。
* 生成的视频均带有声音；本模型没有关闭声音的参数。
* 参考视频支持 mp4 / mov，单段 3 \~ 30 秒，全部参考视频合计不超过 30 秒；参考音频支持 mp3。
* `reference_video_type` 和 `keep_original_sound` 只在传入 `reference_video_urls` 时有效。
* 2K、4K 为超分输出，按对应分辨率的单价计费。
* 失败的任务返回 `status: "failed"`，原因在 `error.message` 中（例如 `InvalidParameterValue: Please input the ImageURL that can be retrieved from the external network.`），不扣费。
* 创建任务时按请求的预估价格预先冻结余额，任务完成后按实际用量结算：未传参考视频时按“分辨率单价 × 时长”预估，传入参考视频时按“有参考视频单价 ×（输出时长 + 30 秒）”预估。余额不足时创建请求直接返回 HTTP 402（`insufficient_balance`），不创建任务。
* 参数不合法的请求返回 HTTP 400，不创建任务、不扣费。时长和素材数量超出范围时，错误信息会指出字段和允许范围（形如 `input.duration must be a number between <最小值> and <最大值>`）；`resolution`、`aspect_ratio` 等枚举参数取值不在允许列表内时，错误信息是通用的，不会指出具体字段，请对照参数表检查。素材格式和内容由模型校验：不符合要求时任务以 `failed` 结束，同样不扣费。
* 视频生成需要数分钟，建议每 10 \~ 15 秒查询一次任务，不要更频繁。


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