# Kling 4.0 Video Generator (`superlewis/kling-4-0-video-generator`) Actor

Generate videos with Kling 4.0 from text, a first and last frame, or up to 10 reference images. 720p or 1080p, 3-15 seconds, sound included. Pay per second on Apify, or use your own apimodels.app API key. Failed jobs are not charged.

- **URL**: https://apify.com/superlewis/kling-4-0-video-generator.md
- **Developed by:** [Lucas Lewis](https://apify.com/superlewis) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $197.00 / 1,000 720p video, per seconds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Kling 4.0 video generator

Generate videos with **Kling 4.0** from a list of prompts. You can work from text alone, animate a **first frame** (with an optional last frame), or build the scene from up to **10 reference images**. Output is 720p or 1080p, 3 to 15 seconds, and **sound is always included**. Each video comes back as a URL in a dataset.

The Actor runs on the [apimodels.app Kling 4.0 API](https://apimodels.app/docs/kling-4-0?utm_source=apify\&utm_medium=referral).

### What you can make

- **Text-to-video** at 16:9, 9:16, 1:1 or 21:9.
- **Image-to-video**: give a first frame and optionally a last frame. The clip follows your image's shape.
- **Reference images**: cite them in the prompt as `@image_1`, `@image_2` and so on. Use them for characters, products, outfits or locations.
- **Sound**: generated with every clip at no extra cost.

### Pricing

Billed per second of delivered video. **Failed generations and content-safety rejections are never charged.**

**Pay per second on Apify** (paid Apify plans, no API key needed):

| Resolution | Per second | 5-second clip | 10-second clip |
|---|---|---|---|
| 720p | $0.197 | $0.985 | $1.97 |
| 1080p | $0.294 | $1.47 | $2.94 |

**Or use your own apimodels.app API key.** Create a key at [apimodels.app](https://apimodels.app/console/api-keys?utm_source=apify\&utm_medium=referral) and paste it into the input. Videos are then billed to your apimodels.app balance at [apimodels.app prices](https://apimodels.app/models/kling-4.0?utm_source=apify\&utm_medium=referral), and nothing is charged on Apify. **On the Apify free plan an API key is required.**

### How to use

1. Enter one or more prompts. Each prompt makes one video.
2. Pick the resolution, duration and aspect ratio.
3. Optional: add a first frame (and last frame) URL, **or** reference image URLs.
4. Optional: paste your apimodels.app API key.
5. Start the run. Videos appear in the **Output** tab as they finish.

### Output

```json
{
  "ok": true,
  "videoUrl": "https://r2.apimodels.app/...mp4",
  "prompt": "A golden retriever runs through shallow waves...",
  "model": "kling-4.0",
  "mode": "text-to-video",
  "resolution": "720p",
  "duration": 5,
  "aspectRatio": "16:9",
  "billing": "apify",
  "taskId": "..."
}
```

If a job fails, its item has `"ok": false` and an `error` message. It is not charged.

### Things to know

- First/last frames and reference images cannot be combined in one job.
- Reference images need at least 300 px per side and an aspect ratio between 0.4 and 2.5.
- Result URLs are kept for **30 days**. Download what you want to keep.
- Use **Maximum cost per run** to cap spending. The Actor stops before it goes over the cap.

### Call the API directly

```bash
curl https://api.apimodels.app/v1/video/generations \
  -H "Authorization: Bearer $APIMODELS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kling-4.0", "prompt": "a hummingbird hovering over a red flower, macro", "resolution": "720p", "duration": 5, "aspect_ratio": "16:9"}'
```

The call returns a `taskId`; poll `GET /v1/video/generations?task_id=...` for the result. The API also supports reference videos, multi-subject elements, voices and middle keyframes. Docs: [apimodels.app/docs/kling-4-0](https://apimodels.app/docs/kling-4-0?utm_source=apify\&utm_medium=referral).

### About apimodels.app

[apimodels.app](https://apimodels.app/?utm_source=apify\&utm_medium=referral) gives you one API key for 170+ AI models: LLMs, image, video and audio generation. Failed requests are never charged.

This Actor is not affiliated with or endorsed by Kuaishou or Kling AI.

# Actor input Schema

## `prompts` (type: `array`):

One job per prompt (up to 20 per run). Refer to reference images as @image_1, @image_2 and so on.

## `resolution` (type: `string`):

720p or 1080p.

## `duration` (type: `integer`):

3 to 15 seconds. Billed per second.

## `aspectRatio` (type: `string`):

Ignored for image-to-video, which follows the first frame.

## `firstFrameUrl` (type: `string`):

Public image URL. Animates this image (image-to-video). Cannot be combined with reference images.

## `lastFrameUrl` (type: `string`):

Public image URL the clip should end on. Needs a first frame.

## `referenceImageUrls` (type: `array`):

Up to 10 public image URLs for characters, products or scenes. Cite them in the prompt as @image_1, @image_2 and so on. Cannot be combined with first/last frames.

## `apiKey` (type: `string`):

Leave empty on a paid Apify plan to pay per second on Apify. Required on the Apify free plan: create a key at https://apimodels.app/console/api-keys and jobs are billed to your apimodels.app balance instead (nothing is charged on Apify).

## Actor input object example

```json
{
  "prompts": [
    "A golden retriever runs through shallow waves on an empty beach at sunset, slow motion, low tracking shot"
  ],
  "resolution": "720p",
  "duration": 5,
  "aspectRatio": "16:9"
}
```

# Actor output Schema

## `results` (type: `string`):

One item per generated video with its URL (kept for 30 days) and settings, plus an error message for jobs that failed.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "prompts": [
        "A golden retriever runs through shallow waves on an empty beach at sunset, slow motion, low tracking shot"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("superlewis/kling-4-0-video-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "prompts": ["A golden retriever runs through shallow waves on an empty beach at sunset, slow motion, low tracking shot"] }

# Run the Actor and wait for it to finish
run = client.actor("superlewis/kling-4-0-video-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "prompts": [
    "A golden retriever runs through shallow waves on an empty beach at sunset, slow motion, low tracking shot"
  ]
}' |
apify call superlewis/kling-4-0-video-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,superlewis/kling-4-0-video-generator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/vsgtMsDa9bdHdWLQh/builds/7FF2vZ9hWvaPXXMfR/openapi.json
