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

# Kling 4.0

> Generate videos with Kling 4.0. See supported inputs, parameters, pricing, response fields, and API examples.

Generate high-quality AI videos using Kling 4.0, Kuaishou's flagship model. Supports text-to-video, up to 10 raw reference images, persistent subject/object elements, keyframes (start, up to 8 middle frames, end), video transform, video reference, and multi-shot generation. Clips run 3–30 seconds with native stereo audio on by default, a new 21:9 ultrawide ratio, and prompts up to 8,000 tokens.

More on this model: [Kling 4.0 API page](https://unifically.com/models/kling-4.0).

## Model

```
kuaishou/kling-4.0-video
```

## Parameters

| Parameter | Type | Required | Default | Description |
| - | - | - | - | - |
| `video_mode` | string | No | - | Input mode. Allowed: `"elements"`, `"start_end_frame"`, `"transform"`, `"video_reference"`. Omit for text-to-video |
| `prompt` | string | Conditional | - | Text prompt (up to 8,000 tokens). Use `@Image1`, `@Element1` to reference inputs. Mutually exclusive with `multi_shots` |
| `mode` | string | No | `"std"` | `"std"` (720p) or `"pro"` (1080p); see [Pricing](#pricing). 4K is not available yet and is rejected |
| `duration` | integer | No | `3` | Video length in seconds (3–30). Ignored when `video_url` is set (the source video's length is used) |
| `aspect_ratio` | string | No | - | `"auto"`, `"1:1"`, `"9:16"`, `"16:9"`, or `"21:9"`. Must be `"auto"` when `video_url` is set. Omit to let the server choose (`"auto"` if `video_url` or `start_end_frame`, else `"16:9"`) |
| `native_audio` | boolean | No | `true` | Generate AI audio (two-channel stereo). On by default for 4.0 |
| `keep_audio` | boolean | No | `true` | Preserve original audio from the source video (`transform` / `video_reference` modes) |
| `image_urls` | string\[] | No | - | Raw reference image URLs uploaded per request (max 10). No description, no reuse. Use `@Image1`, `@Image2` in `prompt` |
| `start_image_index` | integer | No | - | 1-based index into `image_urls` marking which reference image anchors the first frame. No end-frame equivalent |
| `elements` | ElementInput30\[] | No | - | Persistent subject/object assets (max 7, of which at most 3 `type: "video"`). Auto-created on Kling and auto-deleted if submit fails. Use `@Element1`, `@Element2` in `prompt`. Coexists with `image_urls` |
| `start_frame_url` | string | No | - | First frame image URL (`start_end_frame` mode) |
| `keyframe_urls` | string\[] | No | - | Middle keyframe image URLs, in order, between `start_frame_url` and `end_frame_url` (`start_end_frame` mode, max 8). 4.0 only |
| `end_frame_url` | string | No | - | Last frame image URL (`start_end_frame` mode) |
| `video_url` | string | No | - | Source video URL (`transform` / `video_reference` modes). Billed per second of the source video at the with-video rate |
| `multi_shots` | array | No | - | Multi-shot sequence (2–6 shots, each with `prompt` and `duration`, total 3–30 s). Mutually exclusive with `prompt`. Not available in `start_end_frame` mode |
| `nsfw_check` | boolean | No | `true` | Check uploaded media inputs for NSFW content |

## Modes

| Mode | Required inputs | Optional inputs | Notes |
| - | - | - | - |
| *omitted* (text-to-video) | `prompt` or `multi_shots` | — | Rejects every input field including `elements`, `image_urls`, `start_frame_url`, `video_url` |
| `elements` | At least one of `image_urls`, `elements` | — | Combined `image_urls` + `elements` cap of **15** (`image_urls` ≤ 10, `elements` ≤ 7). `video_url` rejected |
| `start_end_frame` | `start_frame_url` | `keyframe_urls`, `end_frame_url` | Keyframes mode. At most **10** frames in total (start + middle + end). `aspect_ratio` is ignored (the frames set it). `elements` and `multi_shots` rejected |
| `transform` | `video_url` | `image_urls`, `elements` | Combined `image_urls` + `elements` cap of **14** (the source video is the 15th reference). `aspect_ratio` must be `"auto"`. Source video short side must be at least 700 px |
| `video_reference` | `video_url` | `image_urls`, `elements` | Combined `image_urls` + `elements` cap of **14**. `aspect_ratio` must be `"auto"` |

<Note>
  **Text-to-video with elements** — set `video_mode: "elements"` and pass only the `elements` array (no `image_urls` required). The omit-`video_mode` path is strictly for pure text-to-video with **zero** inputs; any reference (image or element) requires `elements` mode.
</Note>

<Note>
  **Not available yet on Kling 4.0** — 4K output, 10-bit HDR, video extension, voice references, multi-clip video editing, and Kling 4.0 Flash. Requests for `mode: "4k"` are rejected.
</Note>

## Pricing

Billed per second of output video. With a source video (`transform` / `video_reference` modes) the with-video rate applies, billed per second of the input video.

| Mode | Resolution | Per second | With source video |
| - | - | - | - |
| `std` | 720p | \$0.141 | \$0.169 |
| `pro` | 1080p | \$0.212 | \$0.254 |

A 10% launch sale applies to all four rates until 2026-10-29 01:00 UTC.

## Reference images vs elements

* **`image_urls`** — raw images uploaded per request. Single-use, no description, no reuse across tasks. Cap 10. Reference in `prompt` as `@Image1`, `@Image2`, …
* **`elements`** — persistent subject/object assets stored on the Kling account. Auto-created from your input on submit and auto-deleted if the submit fails. Cap 7, at most 3 video-based. Reference in `prompt` as `@Element1`, `@Element2`, …

Both can be used together; they share the per-mode combined cap (15 in `elements` mode, 14 plus the source video in `transform` / `video_reference`).

## Elements

Kling 4.0 supports both IMAGE and VIDEO elements. Unlike 3.0 Omni, a video-type element may be combined with `video_url`; at most 5 video inputs in total (`video_url` plus video-type elements).

```json theme={null}
"elements": [
  {"description": "Woman in red jacket", "type": "image", "image_urls": ["front.jpg", "side.jpg"]},
  {"description": "Man dancing", "type": "video", "video_url": "dance.mp4"}
]
```

Each element accepts:

| Parameter | Type | Default | Description |
| - | - | - | - |
| `description` | string | `""` | Short description of the element (max 100 chars) |
| `type` | string | `"image"` | Element source type: `"image"` or `"video"` |
| `image_urls` | string\[] | - | Source image URLs for an image element (max 4) |
| `video_url` | string | - | Source video URL for a video element |
| `nsfw_check` | boolean | No | Check uploaded media inputs for NSFW content. Default: `true` |

## Example - Text-to-Video

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "prompt": "A majestic eagle soaring through mountain peaks at sunset",
      "duration": 10,
      "mode": "pro",
      "aspect_ratio": "21:9"
    }
  }'
```

## Example - With Elements

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "video_mode": "elements",
      "prompt": "@Element1 walks through a park at sunset",
      "elements": [
        {"description": "Woman in red jacket", "type": "image", "image_urls": ["https://example.com/front.jpg"]}
      ],
      "duration": 10,
      "mode": "pro"
    }
  }'
```

## Example - Reference Images with Start Frame

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "video_mode": "elements",
      "prompt": "@Image2 walks toward @Image1 across a meadow",
      "image_urls": [
        "https://example.com/character.jpg",
        "https://example.com/scene.jpg"
      ],
      "start_image_index": 2,
      "duration": 5,
      "mode": "pro"
    }
  }'
```

## Example - Keyframes

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "video_mode": "start_end_frame",
      "prompt": "A seed sprouts, grows into a sapling, and blooms",
      "start_frame_url": "https://example.com/seed.jpg",
      "keyframe_urls": [
        "https://example.com/sprout.jpg",
        "https://example.com/sapling.jpg"
      ],
      "end_frame_url": "https://example.com/bloom.jpg",
      "duration": 15,
      "mode": "pro"
    }
  }'
```

## Example - Transform

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "video_mode": "transform",
      "prompt": "Restyle the video as stop-motion claymation",
      "video_url": "https://example.com/source.mp4",
      "mode": "pro"
    }
  }'
```

## Example - Multi-Shot

```bash theme={null}
curl -X POST https://api.unifically.com/v1/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "kuaishou/kling-4.0-video",
    "input": {
      "mode": "pro",
      "multi_shots": [
        { "prompt": "Wide shot of city skyline", "duration": 10 },
        { "prompt": "Close-up of glass buildings", "duration": 10 }
      ]
    }
  }'
```

## Response

```json theme={null}
{
  "code": 200,
  "success": true,
  "data": {
    "task_id": "abc123def456",
    "status": "processing"
  }
}
```

<Note>
  **Volume discounts** are available for almost all models. Reach out at [contact@unifically.com](mailto:contact@unifically.com) to discuss custom pricing.
</Note>


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