# Kling 4.0 Video Editing

> Kling 4.0 edits an input video using text instructions and optional image references, producing 3 to 30-second videos at 720p or 1080p. Kling 4.0 is available in the playground and fal Agent. API access is coming soon.


## Overview

- **Endpoint**: `https://fal.run/kling/v4/video-to-video/edit`
- **Model ID**: `kling/v4/video-to-video/edit`
- **Category**: video-to-video
- **Kind**: inference
**Tags**: video-to-video, video-editing, image-reference, kling



## Pricing

Video costs **$0.094** per second at **720p** and **$0.141** per second at **1080p**, billed on the input plus output length (minimum 2× the output).

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _required_):
  Edit instruction. Reference the source video as @Video1.
  - Examples: "Change the background to a tropical island at sunset."

- **`video_url`** (`string`, _required_):
  The video to edit (3-30s), referenced as @Video1.
  
  Max file size: 300.0MB, Min width: 700px, Min height: 700px, Max width: 4553px, Max height: 4553px, Min aspect ratio: 0.40, Max aspect ratio: 2.50, Min duration: 3.0s, Max duration: 30.05s, Min FPS: 23.9, Max FPS: 60.05, Timeout: 30.0s

- **`image_urls`** (`list<string>`, _optional_):
  Reference images, referenced as @Image1, @Image2, ...
  - Array of string
  - Examples: null

- **`elements`** (`list<KlingV4ImageElement>`, _optional_):
  Characters/objects, referenced as @Element1, @Element2, ...
  - Array of KlingV4ImageElement
  - Examples: null

- **`duration`** (`integer`, _optional_):
  Output duration in seconds (3-30). Defaults to the source video's length.
  - Range: `3` to `30`
  - Examples: null

- **`resolution`** (`ResolutionEnum`, _optional_):
  Output resolution. Default value: `"1080p"`
  - Default: `"1080p"`
  - Options: `"720p"`, `"1080p"`



**Required Parameters Example**:

```json
{
  "prompt": "Change the background to a tropical island at sunset.",
  "video_url": ""
}
```

**Full Example**:

```json
{
  "prompt": "Change the background to a tropical island at sunset.",
  "video_url": "",
  "image_urls": null,
  "elements": null,
  "duration": null,
  "resolution": "1080p"
}
```


### Output Schema

The API returns the following output format:

- **`video`** (`File`, _required_):
  The generated video.
  - Examples: {"content_type":"video/mp4","file_name":"output.mp4","file_size":3478246,"url":"https://v3b.fal.media/files/b/0aac4496/QzdMSy4uSKyFfMjtU65MA_clip_text.mp4"}



**Example Response**:

```json
{
  "video": {
    "content_type": "video/mp4",
    "file_name": "output.mp4",
    "file_size": 3478246,
    "url": "https://v3b.fal.media/files/b/0aac4496/QzdMSy4uSKyFfMjtU65MA_clip_text.mp4"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/kling/v4/video-to-video/edit \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "Change the background to a tropical island at sunset.",
     "video_url": ""
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "kling/v4/video-to-video/edit",
    arguments={
        "prompt": "Change the background to a tropical island at sunset.",
        "video_url": ""
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("kling/v4/video-to-video/edit", {
  input: {
    prompt: "Change the background to a tropical island at sunset.",
    video_url: ""
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/kling/v4/video-to-video/edit)
- [API Documentation](https://fal.ai/models/kling/v4/video-to-video/edit/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=kling/v4/video-to-video/edit)

### fal.ai Platform

- [Platform Documentation](https://fal.ai/docs/documentation)
- [Python Client](https://fal.ai/docs/api-reference/client-libraries/python)
- [JavaScript Client](https://fal.ai/docs/api-reference/client-libraries/javascript)

### Other agent-readable surfaces

This file covers one model. To find anything else:

- [Platform overview](https://fal.ai/llms.txt): Entry points and representative endpoint IDs
- [Documentation index](https://fal.ai/docs/llms.txt): Every documentation page
- [Full documentation text](https://fal.ai/docs/llms-full.txt): The whole documentation inlined
- Any other model: `https://fal.ai/models/<endpoint-id>/llms.txt`
