# Kling 4.0

> Kuaishou's Kling 4.0 on the Kinovi API — text-to-video, multi-keyframe image-to-video (up to 10 frames), and reference-to-video at 720p or 1080p, 3–30 s.

Source: https://kinovi.ai/docs/models/kling-4.0

- Model ID: `kling-4.0/text-to-video`
- Type: Video
- Provider: Kuaishou
- From: $0.0756 / s
- Model page: https://kinovi.ai/models/kling-4-0-text-to-video
- Playground: https://kinovi.ai/app/gallery?model=kling-4.0%2Ftext-to-video

## Models in this series

Kling 4.0 ships as three public faces, each mapped to its dedicated upstream endpoint. Pick the `model` id that matches your input mode — a face never silently falls back to another mode.

| Model ID | Mode | Inputs | Model page |
|:--|:--|:--|:--|
| `kling-4.0/text-to-video` | Text to video | Prompt only | [Kling 4.0 Text to Video](https://kinovi.ai/models/kling-4-0-text-to-video) |
| `kling-4.0/image-to-video` | Image / keyframes to video | 1–10 ordered keyframe images (`imageUrls`) + prompt | [Kling 4.0 Image to Video](https://kinovi.ai/models/kling-4-0-image-to-video) |
| `kling-4.0/reference-to-video` | Reference to video | Up to 10 images (`imageUrls` + `keyframeUrls` combined) and up to 5 reference videos (`videoUrls`) + prompt | [Kling 4.0 Reference to Video](https://kinovi.ai/models/kling-4-0-reference-to-video) |

## Quickstart

Two calls: submit a task with `createTask`, then poll `recordInfo` with the returned `taskId` until `status` is `success` or `fail`.

Every request carries `Authorization: Bearer <yourApiKey>`. Create and manage keys at [kinovi.ai/api-keys](https://kinovi.ai/api-keys); see the [API reference](https://kinovi.ai/docs/api) for rate limits and error codes.

### Submit a task

`POST https://kinovi.ai/api/v1/jobs/createTask`

```json
{
  "model": "kling-4.0/text-to-video",
  "inputs": {
    "prompt": "A cinematic tracking shot through a neon-lit Tokyo alley in light rain, wet asphalt reflecting red lanterns, natural ambient street sound.",
    "aspectRatio": "16:9",
    "duration": 10,
    "resolution": "1080p"
  }
}
```

Response `200 OK` — the task is queued and credits are reserved. Use `taskId` to poll for the result.

```json
{
  "taskId": "task_01j9examplekling400001"
}
```

#### Error responses

| HTTP | Body | When |
|:--|:--|:--|
| `400` | `{ "message": "Invalid inputs for model", "errors": [ … ] }` | Invalid face combination (e.g. `imageUrls` on `text-to-video`, `aspectRatio: "adaptive"` on `text-to-video`, `audio` on non-reference face, or `duration` outside `3`–`30`). Nothing is charged. |
| `401` | `{ "message": "Invalid API Key" }` | Missing or wrong `Authorization` header. |
| `402` | `{ "message": "Insufficient credits", "required": 407, "available": 0 }` | Not enough credits for this duration × resolution. |
| `429` | `{ "message": "Concurrency limit reached (…)", "limit": 5, "current": 5 }` | Too many tasks in progress; wait for one to finish. |

### Query the result

`GET https://kinovi.ai/api/v1/jobs/recordInfo?taskId=task_…`

Poll every few seconds until `status` is `success` or `fail`.

| `status` | Meaning |
|:--|:--|
| `waiting` | Queued, not started yet |
| `generating` | Running |
| `success` | Done — read `output[].url` |
| `fail` | Failed — see `error.code` / `error.message`; credits are refunded |

## Parameters

Send these inside the `createTask` body. `model` and `inputs.prompt` are required on all three faces; everything else falls back to the default shown.

Reference media fields take any publicly reachable URL — host the files yourself, or upload them to Kinovi first with `POST /api/v1/uploads` and pass the returned `url` (see [Uploading Assets](https://kinovi.ai/docs/uploads)).

| Field | Type | Default | Applies to | Description |
|:--|:--|:--|:--|:--|
| `model` | `string` | **required** | All | `kling-4.0/text-to-video` · `kling-4.0/image-to-video` · `kling-4.0/reference-to-video`. |
| `inputs.prompt` | `string` | **required** | All | Scene description and motion instructions. Up to **26,000** ASCII characters or **11,000** non-ASCII characters (mixed prompts must satisfy `E/26000 + N/11000 <= 1`). |
| `inputs.duration` | `integer` | `10` | All | Clip length in whole seconds, `3` to `30`. |
| `inputs.resolution` | `string` | `1080p` | All | `720p` · `1080p`. |
| `inputs.aspectRatio` | `string` | `16:9` (T2V) / `adaptive` (Ref) | T2V, Ref | T2V: `21:9` · `16:9` · `9:16` · `1:1`. Ref adds `adaptive`. Image-to-video follows the keyframes' aspect ratio. |
| `inputs.imageUrls` | `string[]` | – | I2V (**required**), Ref | I2V: **1–10** keyframe images in playback order (first = opening frame, last = closing frame, middle = intermediate frames). Ref: up to **10** subject/style reference images, cited as `@image_1`, `@image_2`… Each side ≥ 300 px, aspect ratio 2:5–5:2. Your own hosted URLs or [Kinovi uploads](https://kinovi.ai/docs/uploads). |
| `inputs.videoUrls` | `string[]` | – | Ref only | Up to **5** MP4 reference videos, each **3–30 s** and **≤ 30 s** combined. Cited in prompt as `@video_1`, `@video_2`… Switches billing to the reference-video per-second rate. Your own hosted URLs or [Kinovi uploads](https://kinovi.ai/docs/uploads). |
| `inputs.keyframeUrls` | `string[]` | – | Ref only | Optional keyframes in playback order. `imageUrls` + `keyframeUrls` combined cannot exceed **10** images. Your own hosted URLs or [Kinovi uploads](https://kinovi.ai/docs/uploads). |
| `inputs.audio` | `string` | `native` | Ref only | `native` (generate audio) · `original` (keep reference video audio; requires at least one entry in `videoUrls`). |
| `callBackUrl` | `string` | – | All | Optional webhook called when the task finishes. |

`inputs.imageUrl` and `inputs.uploadedUrls` are accepted as aliases for `inputs.imageUrls`, but only one image field may be sent per request.

### Full request (reference-to-video)

```json
{
  "model": "kling-4.0/reference-to-video",
  "inputs": {
    "prompt": "The character from @image_1 walks across the rainy plaza following the camera arc from @video_1.",
    "imageUrls": [
      "https://static.kinovi.ai/generated-images/task_ff01ii3zvib7ndbx8negnh6q-0.png"
    ],
    "videoUrls": [
      "https://static.kinovi.ai/videos/seedance_video_1775631198994_17cd129c.mp4"
    ],
    "aspectRatio": "adaptive",
    "duration": 10,
    "resolution": "1080p",
    "audio": "native"
  },
  "callBackUrl": "https://example.com/hooks/kinovi"
}
```

## Pricing

Priced **per second of video**, by `resolution`. Live prices: [Text to Video](https://kinovi.ai/models/kling-4-0-text-to-video) · [Image to Video](https://kinovi.ai/models/kling-4-0-image-to-video) · [Reference to Video](https://kinovi.ai/models/kling-4-0-reference-to-video).

| | 720p | 1080p |
|:--|--:|--:|
| **Standard (T2V, I2V, Ref without video)** | $0.1260 / s | $0.1890 / s |
| **Reference-to-video with `videoUrls` (per billable second)** | $0.0756 / s | $0.1134 / s |

When `videoUrls` is supplied on `kling-4.0/reference-to-video`, billable seconds equal `input_duration + output_duration`, settled on success at the reference-video rate. Without `videoUrls`, `duration` × the standard rate is charged at submit. Failed tasks are refunded in full.

## Response

### Result fields

**JSON**

```json
{
  "taskId": "task_01j9examplekling400001",
  "model": "kling-4.0/text-to-video",
  "status": "success",
  "creditsUsed": 407.33,
  "output": [
    {
      "url": "https://static.kinovi.ai/videos/kling40_example.mp4",
      "width": 1920,
      "height": 1080,
      "mediaType": "video/mp4"
    }
  ],
  "error": null,
  "createTime": 1790090613532,
  "completeTime": 1790090901200
}
```

**Table**

| Field | Type | Description |
|:--|:--|:--|
| `taskId` | `string` | The task id returned by `createTask`. |
| `model` | `string` | The Kling 4.0 face id submitted. |
| `status` | `string` | `waiting` · `generating` · `success` · `fail`. Stop polling on `success` or `fail`. |
| `creditsUsed` | `number` | Credits actually charged. Refunded automatically when `status` is `fail`. |
| `output` | `object[]` | Generated video; empty until `success`. Stored by Kinovi for 7 days after generation. |
| `output[0].url` | `string` | Download URL of the `.mp4` clip. |
| `output[0].width` | `integer` | Pixel width. |
| `output[0].height` | `integer` | Pixel height. |
| `output[0].mediaType` | `string` | `video/mp4`. |
| `error` | `object \| null` | `{ code, message }` when the task failed, otherwise `null`. |
| `createTime` | `number` | Unix epoch milliseconds when the task was accepted. |
| `completeTime` | `number \| null` | Unix epoch milliseconds when the task reached a terminal status. |

## Examples

### Text to video (`kling-4.0/text-to-video`)

**cURL**

```bash
curl -sS -X POST "https://kinovi.ai/api/v1/jobs/createTask" \
  -H "Authorization: Bearer $KINOVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0/text-to-video",
    "inputs": {
      "prompt": "A steam locomotive crossing a misty stone viaduct at dawn, wide aerial tracking shot.",
      "aspectRatio": "16:9",
      "duration": 5,
      "resolution": "1080p"
    }
  }'
```

**Node.js**

```ts
const API_BASE = "https://kinovi.ai/api/v1";
const headers = {
  Authorization: `Bearer ${process.env.KINOVI_API_KEY}`,
  "Content-Type": "application/json",
};

const { taskId } = await fetch(`${API_BASE}/jobs/createTask`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    model: "kling-4.0/text-to-video",
    inputs: {
      prompt: "A steam locomotive crossing a misty stone viaduct at dawn, wide aerial tracking shot.",
      aspectRatio: "16:9",
      duration: 5,
      resolution: "1080p",
    },
  }),
}).then((r) => r.json());

while (true) {
  const info = await fetch(`${API_BASE}/jobs/recordInfo?taskId=${encodeURIComponent(taskId)}`, { headers }).then((r) =>
    r.json(),
  );
  if (info.status === "success") {
    console.log(info.output[0].url);
    break;
  }
  if (info.status === "fail") throw new Error(JSON.stringify(info.error));
  await new Promise((r) => setTimeout(r, 3000));
}
```

**Python**

```python
import json, os, time, urllib.request

API_BASE = "https://kinovi.ai/api/v1"
HEADERS = {
    "Authorization": f"Bearer {os.environ['KINOVI_API_KEY']}",
    "Content-Type": "application/json",
}

payload = {
    "model": "kling-4.0/text-to-video",
    "inputs": {
        "prompt": "A steam locomotive crossing a misty stone viaduct at dawn, wide aerial tracking shot.",
        "aspectRatio": "16:9",
        "duration": 5,
        "resolution": "1080p",
    },
}

req = urllib.request.Request(f"{API_BASE}/jobs/createTask", data=json.dumps(payload).encode(), headers=HEADERS)
task_id = json.load(urllib.request.urlopen(req))["taskId"]

while True:
    info = json.load(urllib.request.urlopen(urllib.request.Request(f"{API_BASE}/jobs/recordInfo?taskId={task_id}", headers=HEADERS)))
    if info["status"] == "success":
        print(info["output"][0]["url"])
        break
    if info["status"] == "fail":
        raise RuntimeError(info["error"])
    time.sleep(3)
```

### Image / keyframes to video (`kling-4.0/image-to-video`)

**cURL**

```bash
curl -sS -X POST "https://kinovi.ai/api/v1/jobs/createTask" \
  -H "Authorization: Bearer $KINOVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0/image-to-video",
    "inputs": {
      "prompt": "Smooth camera push-in as soft morning light shifts across the scene.",
      "imageUrls": [
        "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-0.png",
        "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-1.png"
      ],
      "duration": 5,
      "resolution": "1080p"
    }
  }'
```

**Node.js**

```ts
const res = await fetch("https://kinovi.ai/api/v1/jobs/createTask", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KINOVI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "kling-4.0/image-to-video",
    inputs: {
      prompt: "Smooth camera push-in as soft morning light shifts across the scene.",
      imageUrls: [
        "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-0.png",
        "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-1.png",
      ],
      duration: 5,
      resolution: "1080p",
    },
  }),
});
console.log(await res.json());
```

**Python**

```python
import json, os, urllib.request

payload = {
    "model": "kling-4.0/image-to-video",
    "inputs": {
        "prompt": "Smooth camera push-in as soft morning light shifts across the scene.",
        "imageUrls": [
            "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-0.png",
            "https://static.kinovi.ai/generated-images/task_u91bn4h34rr0zy2m5o9z31si-1.png",
        ],
        "duration": 5,
        "resolution": "1080p",
    },
}
req = urllib.request.Request(
    "https://kinovi.ai/api/v1/jobs/createTask",
    data=json.dumps(payload).encode(),
    headers={"Authorization": f"Bearer {os.environ['KINOVI_API_KEY']}", "Content-Type": "application/json"},
)
print(json.load(urllib.request.urlopen(req)))
```

### Reference to video (`kling-4.0/reference-to-video`)

**cURL**

```bash
curl -sS -X POST "https://kinovi.ai/api/v1/jobs/createTask" \
  -H "Authorization: Bearer $KINOVI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-4.0/reference-to-video",
    "inputs": {
      "prompt": "The subject in @image_1 turns toward the camera following the pacing of @video_1.",
      "imageUrls": ["https://static.kinovi.ai/generated-images/task_ff01ii3zvib7ndbx8negnh6q-0.png"],
      "videoUrls": ["https://static.kinovi.ai/videos/seedance_video_1775631198994_17cd129c.mp4"],
      "aspectRatio": "adaptive",
      "duration": 5,
      "resolution": "720p",
      "audio": "native"
    }
  }'
```

**Node.js**

```ts
const res = await fetch("https://kinovi.ai/api/v1/jobs/createTask", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KINOVI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "kling-4.0/reference-to-video",
    inputs: {
      prompt: "The subject in @image_1 turns toward the camera following the pacing of @video_1.",
      imageUrls: ["https://static.kinovi.ai/generated-images/task_ff01ii3zvib7ndbx8negnh6q-0.png"],
      videoUrls: ["https://static.kinovi.ai/videos/seedance_video_1775631198994_17cd129c.mp4"],
      aspectRatio: "adaptive",
      duration: 5,
      resolution: "720p",
      audio: "native",
    },
  }),
});
console.log(await res.json());
```

**Python**

```python
import json, os, urllib.request

payload = {
    "model": "kling-4.0/reference-to-video",
    "inputs": {
        "prompt": "The subject in @image_1 turns toward the camera following the pacing of @video_1.",
        "imageUrls": ["https://static.kinovi.ai/generated-images/task_ff01ii3zvib7ndbx8negnh6q-0.png"],
        "videoUrls": ["https://static.kinovi.ai/videos/seedance_video_1775631198994_17cd129c.mp4"],
        "aspectRatio": "adaptive",
        "duration": 5,
        "resolution": "720p",
        "audio": "native",
    },
}
req = urllib.request.Request(
    "https://kinovi.ai/api/v1/jobs/createTask",
    data=json.dumps(payload).encode(),
    headers={"Authorization": f"Bearer {os.environ['KINOVI_API_KEY']}", "Content-Type": "application/json"},
)
print(json.load(urllib.request.urlopen(req)))
```

## Notes

- **Prompt citations on reference-to-video**: Cite reference images as `@image_1`, `@image_2`, … and reference videos as `@video_1`, `@video_2`, … in the prompt.
- **Multi-keyframe ordering**: On `kling-4.0/image-to-video` (and `keyframeUrls` on `reference-to-video`), frames play in array order: index `0` is the first frame, the last item is the closing frame, and intermediate entries anchor middle beats.

## FAQ

### How many keyframes can I send to `kling-4.0/image-to-video`?

Between **1 and 10** images in `inputs.imageUrls`. With 1 image, it serves as the opening frame; with 2 or more, the first is the opening frame, the last is the closing frame, and any images between them act as intermediate keyframes.

### How is `kling-4.0/reference-to-video` billed when I pass reference videos?

When `videoUrls` is included, Kinovi bills `input_duration + output_duration` at the lower reference-video per-second rate (`$0.0756 / s` at 720p, `$0.1134 / s` at 1080p) and settles the final credits on completion.

### Can I keep the original audio from a reference video?

Yes — on `kling-4.0/reference-to-video`, set `"audio": "original"` alongside at least one clip in `inputs.videoUrls`.

## Related models

- [Seedance 2.5](https://kinovi.ai/docs/models/seedance2-5): ByteDance's 4–30 s video model with up to 30 reference images, 10 videos, and 10 audio clips.
- [Vidu Q4](https://kinovi.ai/docs/models/vidu-q4): Vidu Q4 image-to-video and reference-to-video up to 4K with reference audio support.
- [MAGI-2](https://kinovi.ai/docs/models/magi-2): Sand AI's native 1080p video generation across text, keyframes, and multimodal references.
