API guides

Kling 4.0 API guide: how to call Kling 4.0 and Kling 4.0 Omni

Call Kling 4.0 and Kling 4.0 Omni on DreamTo: the request shape, every parameter, limits, per-second prices, and which model fits frames or references.

A curling ocean wave painted in lime, teal and violet under an aurora sky
On this page

DreamTo serves two Kling 4.0 models through the same video endpoint. kling-4.0 generates a clip from a prompt, a first frame, or a first and last frame, for 3 to 30 seconds with sound, at 720P up to 4K. kling-4.0-omni generates from reference assets instead: up to 10 images, 5 videos and 3 audio clips, and it can also edit an existing video.

This guide covers what each model accepts, every parameter, requests you can copy, prices and limits. The facts come from the API docs for Kling 4.0 and Kling 4.0 Omni and from the model catalog.

Which model to call#

If the input is a prompt, one image or two images, call Kling 4.0. If the input is a set of references that the output has to follow (a character, a product, a voice, a camera move), or a video to edit, call Kling 4.0 Omni.

Kling 4.0 (kling-4.0)Kling 4.0 Omni (kling-4.0-omni)
Text-to-videoYesUse Kling 4.0
First frame (image_url)YesNo
First and last frame (last_frame_url)YesNo
Reference imagesNoUp to 10
Reference videosNoUp to 5, 3-30 s each, 30 s in total
Reference audioNoUp to 3 mp3 clips
Edit an existing videoNoYes (reference_video_type: "base")

Output is the same for both: 3 to 30 seconds at 720P, 1080P, 2K or 4K, in 16:9, 9:16, 1:1 or 21:9, with sound generated together with the picture. Neither model has a parameter to turn the sound off.

Each has a playground for testing without code, Kling 4.0 and Kling 4.0 Omni, and a model page with sample outputs: /kling-4-0 and /kling-4-0-omni.

Create a task, poll it, download the file#

Video generation is asynchronous. Create a task with POST /v1/videos, take the task_id from the response, poll GET /v1/videos/{task_id}, and download the file from video_url once status is completed. The request body has two fields: model, and input, which holds every generation parameter. Neither model has a callback field, so polling is how you follow a task.

Every request carries an API key from the DreamTo console in the Authorization: Bearer header; the authentication page covers creating and storing keys.

statusMeaning
queuedWaiting in the queue
in_progressBeing generated
completedFinished; download from video_url
failedFailed; the reason is in error, and the task is not charged

A video takes several minutes. Poll every 10 to 15 seconds, not faster.

Calling Kling 4.0#

Text-to-video#

A prompt alone makes the request text-to-video, and aspect_ratio sets the frame.

bash
curl -X POST "https://api.dreamto.ai/v1/videos" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "kling-4.0",    "input": {      "prompt": "A red panda walks slowly through fresh snow and looks back at the camera, cinematic, shallow depth of field",      "resolution": "1080P",      "duration": 5,      "aspect_ratio": "16:9"    }  }'

The response carries task_id, status, model, created_at and request_id. Log the request_id: it is what to include when you report a problem. The query response adds completed_at once the task has finished, video_url on success and error on failure.

A complete script with polling#

This script creates a task, polls it every 10 seconds and saves the finished file. It needs the requests package and DREAMTO_API_KEY in your environment.

python
import osimport timeimport requestsBASE_URL = "https://api.dreamto.ai"HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}payload = {    "model": "kling-4.0",    "input": {        "prompt": "A red panda walks slowly through fresh snow and looks back at the camera, cinematic, shallow depth of field",        "resolution": "1080P",        "duration": 5,        "aspect_ratio": "16:9",    },}resp = requests.post(f"{BASE_URL}/v1/videos", headers=HEADERS, json=payload, timeout=60)resp.raise_for_status()task = resp.json()task_id = task["task_id"]print("created", task_id, task["status"])while task["status"] not in ("completed", "failed"):    time.sleep(10)    resp = requests.get(f"{BASE_URL}/v1/videos/{task_id}", headers=HEADERS, timeout=60)    resp.raise_for_status()    task = resp.json()    print(task["status"])if task["status"] == "failed":    raise SystemExit(f"failed: {task.get('error')}")# video_url is valid for 7 days; copy the file to your own storage.video = requests.get(task["video_url"], timeout=300)video.raise_for_status()with open(f"{task_id}.mp4", "wb") as f:    f.write(video.content)print("saved", f"{task_id}.mp4")

The same loop works for Omni; only model and input change.

First frame, and first and last frame#

Send image_url and the video starts from that image; in this mode prompt is optional. Add last_frame_url and the video transitions from the first frame to the last. last_frame_url must be sent together with image_url.

bash
curl -X POST "https://api.dreamto.ai/v1/videos" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "kling-4.0",    "input": {      "prompt": "The camera pushes in slowly as day turns to night and the city lights come on",      "image_url": "https://your-cdn.example.com/first-frame.png",      "last_frame_url": "https://your-cdn.example.com/last-frame.png",      "resolution": "1080P",      "duration": 8    }  }'

With a first frame, aspect_ratio has no effect: the output follows the image. Choose two frames whose aspect ratio and viewing direction agree, and use the prompt for the movement between them. Images must be public URLs in jpeg, jpg or png, up to 10MB each.

30-second clips, 9:16 and 4K#

One generation runs up to 30 seconds, with no stitching. For 15 seconds of vertical 4K, set "resolution": "4K", "duration": 15 and "aspect_ratio": "9:16" in the text-to-video request above.

Native output is 720P and 1080P. 2K and 4K are upscaled, and are billed at the price of that resolution.

Kling 4.0 parameters#

All of these go inside input.

ParameterTypeDefaultValuesNotes
promptstringnonefree textContent, motion and camera work. Required for text-to-video, optional with a first frame
image_urlstringnonepublic URL, jpeg / jpg / png, up to 10MBFirst frame; makes the request image-to-video
last_frame_urlstringnonesame as aboveLast frame; needs image_url
resolutionstring720P720P, 1080P, 2K, 4K
durationinteger53 to 30Seconds
aspect_ratiostringnone16:9, 9:16, 1:1, 21:9Ignored when a first frame is sent

Calling Kling 4.0 Omni#

Omni requires a prompt, and the prompt has to say how each reference is used. The model page describes Kling's Omni Reference convention: tag assets in the prompt (@Image1, @Video1) and give each a role such as subject, motion, camera or style. The request examples in the API docs name assets in plain words ("the girl from the first image and the fox from the second image"). In both styles every asset gets a role.

When a result drifts, the model page suggests two checks. List the details that must carry over (a coat, a product label, a room layout) and look for each in the output. Change one reference per round, so you can tell which asset caused a difference.

Reference images#

Send up to 10 images and say in the prompt what each one is for.

bash
curl -X POST "https://api.dreamto.ai/v1/videos" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "kling-4.0-omni",    "input": {      "prompt": "The girl from the first image and the fox from the second image walk together through a snowy forest, cinematic",      "reference_image_urls": [        "https://your-cdn.example.com/girl.png",        "https://your-cdn.example.com/fox.png"      ],      "resolution": "1080P",      "duration": 5,      "aspect_ratio": "16:9"    }  }'

Reference audio#

Add reference_audio_urls (up to 3 mp3 clips) to any Omni request. This body pairs an image with a voice clip and asks for 21:9 output:

json
{  "model": "kling-4.0-omni",  "input": {    "prompt": "The girl from the reference image speaks to the camera with the voice of the reference audio, on a beach at dusk",    "reference_image_urls": ["https://your-cdn.example.com/girl.png"],    "reference_audio_urls": ["https://your-cdn.example.com/voice.mp3"],    "resolution": "720P",    "duration": 5,    "aspect_ratio": "21:9"  }}

Reference video: feature or base#

reference_video_type decides what a reference video is for.

With feature, the clip is a feature reference for a new video. This body takes the camera move from the clip and applies it to a different scene:

json
{  "model": "kling-4.0-omni",  "input": {    "prompt": "Follow the camera movement of the reference video to film a red sports car driving along a desert road",    "reference_video_urls": ["https://your-cdn.example.com/reference.mp4"],    "reference_video_type": "feature",    "resolution": "720P",    "duration": 5  }}

With base, the clip is the video to edit, and the prompt describes the change. keep_original_sound: true keeps its sound:

json
{  "model": "kling-4.0-omni",  "input": {    "prompt": "Change the season in the video from summer to a snowy winter; keep the people and their motion unchanged",    "reference_video_urls": ["https://your-cdn.example.com/reference.mp4"],    "reference_video_type": "base",    "keep_original_sound": true,    "resolution": "720P",    "duration": 5  }}

Send these bodies to POST /v1/videos with the same headers as the curl requests. reference_video_type and keep_original_sound only apply when reference_video_urls is present. A reference video also changes how the task is billed; see the prices below.

Kling 4.0 Omni parameters#

ParameterTypeRequiredValuesNotes
promptstringYesfree textDescribes the video and how each reference is used
reference_image_urlsstring[]Noup to 10jpeg / jpg / png, up to 10MB each
reference_video_urlsstring[]Noup to 5mp4 / mov, 3-30 s each, 30 s in total
reference_video_typestringNofeature, baseFeature reference, or video to edit
keep_original_soundbooleanNotrue, falseKeeps the reference video's sound
reference_audio_urlsstring[]Noup to 3mp3
resolutionstringNo720P, 1080P, 2K, 4KDefault 720P
durationintegerNo3 to 30Default 5
aspect_ratiostringNo16:9, 9:16, 1:1, 21:9

Prices per second#

Both models are billed per second at the price of the chosen resolution. These are the prices as of December 2026, after a 10% discount off the list price. Prices change; /prices has the current numbers.

ResolutionPer second, no reference videoPer second, with reference video
720P$0.1413$0.0846
1080P$0.2115$0.1269
2K$0.25434$0.152604
4K$0.4941$0.2961

The "with reference video" column applies to Omni requests that include reference_video_urls. Its lower rate is charged on more seconds: the billable duration is the reference video duration plus the output duration when the reference is longer than the output, otherwise twice the output duration.

At the 720P prices above, a 5-second output costs:

RequestBillable secondsCost
No reference video55 × $0.1413 = $0.7065
3-second reference video1010 × $0.0846 = $0.846
10-second reference video1515 × $0.0846 = $1.269

Creating a task reserves its estimated price from your balance, and the charge is settled to actual usage when the task completes. Without a reference video the estimate is the resolution price times the duration. With one, it is the with-reference-video price times the output duration plus 30 seconds. If the balance does not cover the estimate, the request returns HTTP 402 and no task is created.

Failed tasks and invalid requests are not charged.

Limits and errors#

  • video_url is valid for 7 days after completion. Download the file and keep your own copy.
  • Input media must be publicly downloadable URLs. Media hosted outside mainland China also works.
  • An invalid request returns HTTP 400 and creates no task. An out-of-range duration or media count names the field and its allowed range (input.duration must be a number between <min> and <max>). A value outside the allowed list for resolution or aspect_ratio returns a generic message that does not name the field, so check the request against the parameter tables.
  • Media format and content are checked by the model, not at creation. A violation ends the task as failed with the reason in error.message, for example InvalidParameterValue: Please input the ImageURL that can be retrieved from the external network.

Request errors arrive as an HTTP status with an error object that holds code, message, type, http_status and request_id.

HTTPerror.codeWhen
400invalid_requestA required parameter is missing or a value is not allowed
401unauthorizedMissing or invalid API key
402insufficient_balanceBalance below the estimated price
404not_foundQuery: the task does not exist or its result has expired
429rate_limit_exceededToo many requests; retry later
500api_errorQuery: server error; retry later
502service_unavailableCreate: the model service is temporarily unavailable; no task, no charge

Branch on the HTTP status and error.code, not on the message text. The errors page has handling advice for each status.

For test runs, start at 720P, the default and lowest-priced resolution, and raise the resolution and duration once the motion and framing are right.

FAQ#

What is the difference between Kling 4.0 and Kling 4.0 Omni?#

Kling 4.0 generates from text, a first frame, or a first and last frame. Kling 4.0 Omni generates from references (up to 10 images, 5 videos and 3 audio clips) and can edit an existing video. Both output 3 to 30 seconds with sound at 720P to 4K.

How long can a Kling 4.0 video be?#

Both models produce 3 to 30 seconds in one generation, set with an integer duration. The default is 5 seconds.

Does Kling 4.0 generate audio?#

Yes. Every video from either model includes sound, and there is no parameter to turn it off. With Omni, keep_original_sound sets whether a reference video's sound is kept.

Can Kling 4.0 Omni edit an existing video?#

Yes. Send the video in reference_video_urls with reference_video_type set to base, and describe the change in the prompt. The video must be mp4 or mov, 3 to 30 seconds long, and the request is billed at the with-reference-video price.

Is 4K native output?#

No. Native output is 720P and 1080P. 2K and 4K are upscaled and billed at the price of that resolution.

How do I get the finished video?#

Poll GET /v1/videos/{task_id} every 10 to 15 seconds until status is completed, then download video_url. The link is valid for 7 days.

  • Kling 4.0
  • Video API