Custom

Kling 4.0 API : Create AI Videos up to 30 Seconds From Text, Images or a Clip

Try Kling 4.0 online right here: write a prompt, add a first frame, reference images or a clip to edit, choose the aspect ratio, resolution and length, and get a video of 3 to 30 seconds. Then call the same model from your product through the Kling 4.0 API, with one key and one balance.

  • Four modes
  • 3–30 second videos
  • Billed by output length
  • Kling 4.0 API

Features

Key Kling 4.0 API Capabilities

  • Four ways to create with Kling 4.0

    The Kling 4.0 API covers text to video, image to video, reference to video and video edit through one endpoint. Change the mode parameter and keep the rest of your integration as it is.

  • Lifelike motion and camera work

    Kling 4.0 handles fast action, continuous movement, tracking and orbit shots while keeping the scene steady, with realistic lighting and detailed textures. Describe the camera in your prompt and the model follows it.

  • Up to 30 seconds per video

    Set duration anywhere from 3 to 30 seconds. A longer Kling 4.0 video leaves room for a complete moment: an action that builds, a product shown from every side or a full story beat in a single shot.

  • First frame, keyframes and last frame

    In image to video, your first image opens the shot and, with two or more, the last image closes it; the images in between act as keyframes. Up to 10 images tell Kling 4.0 exactly which states the video must pass through.

  • Consistent characters and products

    Reference to video places the people, objects or places from up to 10 reference images or 5 reference videos in a brand-new scene. Video edit changes footage you already have as your prompt says, optionally with reference images and videos.

  • 720p or 1080p, four aspect ratios or auto

    Render Kling 4.0 AI videos at 720p or 1080p in 21:9, 16:9, 9:16 or 1:1, or pass auto. Each video comes back as a public link you can store or serve directly.

Kling 4.0 AI video model on NanoAPI: cinematic shots for the text, image, reference and edit modes above a video timeline

Overview

What Is Kling 4.0?

Model ID
kling-4.0
Modes
4
Length
3–30s
Resolution
720p / 1080p
Aspect ratio
auto · 21:9 · 16:9 · 9:16 · 1:1
Images
Up to 10
Prompt
Up to 8000 characters
Price
From $0.1287 / s

Kling 4.0 is the fourth generation of the Kling AI video model. It turns a prompt, a set of images or an existing clip into a video of 3 to 30 seconds at 720p or 1080p, with natural motion, steady camera moves and detailed light and texture. Prompts can run up to 8,000 characters, so one request can describe several actions, camera changes and a mood.

On NanoAPI, Kling 4.0 is one model with four modes. text_to_video generates from a prompt alone, image_to_video animates from a first frame (optionally with keyframes and a last frame), reference_to_video builds a new scene around up to 10 reference images or 5 reference videos, and video_edit rewrites a clip of up to 30 seconds. Every mode uses the model value kling-4.0.

Use Kling 4.0 online in the studio at the top of this page, then call the Kling 4.0 API at https://api.nanoapi.ai/v1 from your own app. Both draw on the same prepaid balance at the same per-second prices, and a failed generation is never charged.

Modes

Kling 4.0 Modes Compared

One endpoint, four modes: pick the one that matches what you start from. Every mode is billed per second of the video you ask for.

ModeInputBest for720p / s1080p / s
Text to Videotext_to_videoA prompt (required)Concept shots, B-roll and scenes you only have in words$0.1287$0.1872
Image to Videoimage_to_video1–10 images: first frame, keyframes, last frame; optional promptAnimating artwork, product photos and storyboards with a fixed start and end$0.1287$0.1872
Reference to Videoreference_to_videoUp to 10 reference images and/or up to 5 reference videos; optional promptKeeping a character, product or place consistent in a new scene$0.1287$0.1872
Video Editvideo_editA clip (720p or higher, 3–30 s) and a prompt; optional: up to 10 reference images and 4 reference videosSwapping objects or changing the style or setting of footage you already have$0.1521$0.234

Live prices per second of output. The cost is duration × the price (reference to video with reference videos uses the video edit price); failed runs are fully refunded.

How it works

How to Use the Kling 4.0 API

  1. 1

    Step 1: Get your API key

    Sign in to NanoAPI with Google and create a key on the API Keys page of the console. The key authenticates every Kling 4.0 API request, so keep it on your server.

  2. 2

    Step 2: Try Kling 4.0 in the studio

    Test prompts, frames and references in the studio above before you write code. It shows the exact cost before you generate: duration × the price per second of the mode and resolution.

  3. 3

    Step 3: Create a Kling 4.0 video

    Send POST /v1/tasks with model kling-4.0, a mode, your prompt or media and the required aspect_ratio, resolution and duration (video edit can leave duration out). The task is queued in under a second, and its cost is reserved within a few seconds.

  4. 4

    Step 4: Get the result

    Receive the finished task at your webhook_url or poll GET /v1/tasks/{task_id}. Most Kling 4.0 videos are ready in 1 to 5 minutes and come back as a public video URL.

Why NanoAPI

Why Use the Kling 4.0 API on NanoAPI

  • One API for every mode

    The Kling 4.0 API uses the same POST /v1/tasks endpoint, task object and webhooks as every NanoAPI model, so a new mode or model never means a new integration.

  • Pay per second of output

    The cost is duration × the price per second of the mode and resolution, known before you submit. No subscription: top up from $10, and the balance never expires.

  • Failed runs are free

    Each task reserves its cost when it's created and is charged only when the video is ready. If a generation fails, even because a file can't be read, the full amount goes back to your balance.

  • Safe retries and spend limits

    Send an Idempotency-Key and a resent request returns the task it already created instead of charging twice. Cap each key's hourly, daily or total spending in the console.

  • Try online, then integrate

    The studio on this page runs the same Kling 4.0 model at the same prices, so what you test is what your users get. The docs also come as one llms.txt file for AI coding assistants.

  • Live status and real support

    See each model's success rate on the public status page, and write to support@nanoapi.ai with any question about integration, tasks or billing.

Use cases

What You Can Build With the Kling 4.0 API

  • An AI video generator web app built on the Kling 4.0 API, turning a prompt about a lighthouse in a storm into a video

    AI video generator apps

    Turn prompts and uploads into finished clips in your own Kling 4.0 AI video generator, creative tool or content platform.

  • A sneaker ad film still titled “New Drop”: a white running shoe above splashing water

    Ads and marketing videos

    Generate launch videos, social ads and campaign variations from a brief, from product photos or from an existing spot you want to restyle.

  • Three storyboard shots titled “One character, every shot”: the same woman in a yellow raincoat and red scarf in a forest, on a bridge and in a lantern-lit village

    Characters and short stories

    Keep a character consistent across shots with reference images and tell a full beat in up to 30 seconds per shot for short dramas and animated stories.

  • Vertical 9:16 videos and a square 1:1 post for social feeds: latte art, a skateboarder, a puppy on a beach and a mountain lake

    Social media content

    Create vertical 9:16 videos for TikTok, Reels and Shorts, or square 1:1 posts, straight from your scheduling or creator tools.

  • A product photo of a tan leather handbag turned into a product video of the bag on a marble pedestal

    E-commerce product videos

    Animate product photos into showcase clips, or edit existing footage to swap colors, settings or props for every listing.

  • An automated video pipeline: Prompt, Kling 4.0, Webhook and Publish connected in a row

    Automated video pipelines

    Connect the Kling 4.0 API to agents and content pipelines: create tasks in bulk, get the results by webhook and publish without manual steps.

FAQ

Kling 4.0 API FAQ

Can’t find what you need? Write to us.

01

What is the Kling 4.0 API?

The Kling 4.0 API lets your app generate videos with the Kling 4.0 model over HTTP. On NanoAPI you send POST /v1/tasks with model kling-4.0 and one of four modes (text_to_video, image_to_video, reference_to_video or video_edit), then get the finished video by webhook or by polling.

02

How much does the Kling 4.0 API cost?

You pay per second of the video you ask for: duration × the price per second of the mode and resolution (reference to video with reference videos is billed at the video edit price). The live prices are in the table above, on the pricing page and in GET /v1/products, and the studio shows the exact cost before you generate. Failed runs are not charged.

03

Can I try Kling 4.0 online before integrating?

Yes. Sign in and use the studio at the top of this page: it runs the same Kling 4.0 model at the same prices as the API and draws on the same balance, so you can check results and costs before writing code. Top-ups start at $10.

04

How long can Kling 4.0 videos be?

Between 3 and 30 seconds, set in whole seconds with the duration parameter. In video edit, each clip (the one you edit and any reference videos) is 3–30 seconds and all of them together at most 30 seconds; leave duration out and the new video is as long as the clip you edit.

05

Which resolutions and aspect ratios does Kling 4.0 support?

720p and 1080p, in 21:9, 16:9, 9:16 or 1:1. aspect_ratio and resolution are required on every request, and duration in every mode except video edit. auto depends on the mode: it follows the first frame in image to video and the edited clip in video edit, and doesn't follow the reference images in reference to video.

06

What's the difference between image to video and reference to video?

Image to video uses your images as frames of the video: the first one opens it and, with two or more, the last one closes it. Reference to video uses your images (and optional reference videos) as references: the people, objects or places in them appear in a new scene that Kling 4.0 composes freely.

07

How long does a Kling 4.0 video take to generate?

Most videos are ready in 1 to 5 minutes, occasionally around 10. In production, pass a webhook_url to be notified once when the task finishes instead of polling.

08

What happens if a Kling 4.0 generation fails?

The amount reserved for the task goes back to your balance in full, and the task's error.type tells you why, for example an image that can't be downloaded or a clip to edit that is longer than 30 seconds.

Start Creating With Kling 4.0

Try Kling 4.0 in the studio above, then bring the same model into your product with the Kling 4.0 API.