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

# Kling 4.0

> Kling 4.0 video generation with 3-30 second output, multiple keyframes and Omni references.

Kling 4.0 supports text-to-video, keyframe-based image-to-video, and Omni reference generation/editing. Its API currently exposes 720p and 1080p, not 4k. Kling 4.0 Flash is a separate offering and is not implied by this model ID.

Authenticate with a MixRoute Bearer key. Put `kling-4.0` in the endpoint path, not a body model field. Keep the native prompt/contents, settings and options structure; do not wrap it in metadata. These endpoints do not establish support for Kling 4.0 on motion-control.

## Model specifications

| Field | Description |
| - | - |
| `ID` | kling-4.0 |
| `POST` | [Text-to-video](https://mixroute.ai/docs/api-reference/endpoint/kling-text-to-video.md) / [Image-to-video](https://mixroute.ai/docs/api-reference/endpoint/kling-image-to-video.md) / [Omni reference and editing](https://mixroute.ai/docs/api-reference/endpoint/kling-omni-video.md) |

## Shared settings and options

| Field | Description |
| - | - |
| `settings.resolution` | 720p or 1080p. The provider default is 1080p; specify the value explicitly on MixRoute instead of relying on older gateway defaults. |
| `settings.duration` | Integer 3-30 seconds. Provider precedence: explicit setting, then a duration stated in the prompt, then 10 seconds. Omni editing uses rounded base\_video duration before the 10-second fallback. Explicit settings avoid ambiguity. |
| `options` | Common options remain options.callback\_url, options.external\_task\_id and options.watermark\_info.enabled. A custom task ID is not a MixRoute polling ID or an idempotency guarantee. |

English-only: up to 26,000 characters; non-English-only: up to 11,000. Mixed input must satisfy `E / 26000 + N / 11000 <= 1`. Describe action order and camera movement in the prompt; do not copy the older multi\_shot switch. E is the number of English characters and N is the number of non-English characters.

> [!NOTE]
>
> Text/image endpoints have no 4.0 audio or multi\_shot switch. Omit settings.audio and settings.multi\_shot rather than sending the older audio=off configuration.

## Text-to-video

| Field | Description |
| - | - |
| `prompt` | Required root prompt. Text-to-video does not accept media inputs. |
| `settings.aspect_ratio` | 21:9, 16:9, 9:16 or 1:1; provider default 16:9. Do not send adaptive on the text-to-video endpoint. |

Set MIXROUTE\_API\_KEY. Replace example.com media URLs with accessible files. Submit once; a timeout is not proof that a task was not created.

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/text-to-video/kling-4.0" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "prompt": "A red ceramic mug slowly rotates on a white tabletop. Static camera, soft studio lighting.",
  "settings": {
    "resolution": "720p",
    "duration": 3,
    "aspect_ratio": "16:9"
  }
}'
```

## Image-to-video

Use a prompt item plus first\_frame, middle\_frame and/or last\_frame image items. Each image uses url; an optional unique id lets the prompt refer to it as @id. Keep keyframes and prompt references in timeline order. No timestamp field is required by this schema.

At most 10 images. JPG/JPEG/PNG, at most 30 MB each, both dimensions at least 300 px, aspect ratio 2:5 to 5:2. Use public URLs or Base64. Image-to-video has no settings.aspect\_ratio; use Omni for videos, Elements or voice references.

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/image-to-video/kling-4.0" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "type": "prompt",
      "text": "The scene moves smoothly from @start through @middle to @end."
    },
    {
      "type": "first_frame",
      "id": "start",
      "url": "https://example.com/first-frame.png"
    },
    {
      "type": "middle_frame",
      "id": "middle",
      "url": "https://example.com/middle-frame.png"
    },
    {
      "type": "last_frame",
      "id": "end",
      "url": "https://example.com/last-frame.png"
    }
  ],
  "settings": {
    "resolution": "720p",
    "duration": 5
  }
}'
```

## Omni reference and editing

A prompt item is required. Supported inputs: first\_frame, middle\_frame, last\_frame, refer\_image, feature\_video, base\_video, element and voice. Image/video items use url; Elements use element\_id and voices use voice\_id. Assign unique id values and refer to them as @id; element/voice IDs must be accessible to the routed upstream account.

For element and voice items, id is required as well as element\_id or voice\_id.

Image id is required when multiple middle\_frame or refer\_image inputs are provided to Omni. If first\_frame, last\_frame and refer\_image are combined, put the first frame first and last frame last among the image items.

| Field | Description |
| - | - |
| `settings.aspect_ratio` | 21:9, 16:9, 9:16, 1:1 or adaptive (provider default). An explicit ratio wins. Adaptive uses the prompt, then base\_video, then keyframes, then feature\_video; multiple reference videos or no applicable source fall back to 16:9. |
| `settings.audio` | native (provider default) or original. original requires base\_video or feature\_video and excludes voice references. Prefer base\_video audio; otherwise use the first feature\_video. off and multi\_shot are not 4.0 settings. |

### Media limits

Combined images, videos, Elements and voices: at most 15 inputs. Images: at most 10. Reference videos: at most 5, counting video-character Elements toward that limit. Elements: at most 7, including at most 3 video-character Elements. Voices: at most 3. At most one base\_video.

JPG/JPEG/PNG, at most 30 MB per image, both dimensions at least 300 px, aspect ratio 2:5 to 5:2. Use public URLs or Base64.

MP4/MOV, at most 300 MB each; each video and the combined video duration must be 3-30 seconds, including video-character Elements. Dimensions 700-4553 px, total pixels at most 8,294,400; aspect ratio 2:5 to 5:2; input 24-60 fps, output 24 fps.

```bash theme={null}
curl --request POST "https://api.mixroute.ai/kling/omni-video/kling-4.0" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {
      "type": "prompt",
      "text": "A slow camera move around the ceramic mug in @mug on a white tabletop."
    },
    {
      "type": "refer_image",
      "id": "mug",
      "url": "https://example.com/mug.png"
    }
  ],
  "settings": {
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "adaptive",
    "audio": "native"
  }
}'
```

## Task results

Check HTTP status and code=0, save submission data.id, and query that single MixRoute task ID. After succeeded, read the video URL from data\[0].outputs where type=video. Keep API keys away from the result CDN.

```bash theme={null}
curl --get "https://api.mixroute.ai/kling/tasks" \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --data-urlencode "task_ids=$KLING_TASK_ID"
```

[Task results](https://mixroute.ai/docs/api-reference/endpoint/kling-tasks.md)

For Kling 4.0, upstream billing distinguishes input\_duration and output\_duration; input includes reference videos and video-character Elements. Gateway usage may be absent or empty. Do not infer final MixRoute charges solely from outputs\[].duration or apply older model rates. Use the Model Marketplace and console bill.


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