Kling Text-to-Video
Create a text-to-video task and follow it through completion or failure.
Overview
Create an asynchronous text-to-video task with a supported model. Use the returned task ID to retrieve its state, or provide callback_url for terminal delivery.
Quick start
- Create an API key and set it as RUNAPI_API_KEY.
- Choose a supported model and send a POST request whose body matches that model's schema.
- Store the returned task ID, then poll until a terminal state or handle the terminal callback.
Endpoint
- Base URL
https://runapi.ai- API version
v1- Authentication
Authorization: Bearer YOUR_API_TOKEN
Supported models
Open a model page for current pricing, rate limits, and commercial-usage details.
Request schema
Fields and allowed values depend on the selected model. When supplied, callback_url receives a terminal task delivery.
kling-3.014 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
callback_urlstringWebhook URL for async notifications.
cfg_scalenumberGuidance scale (0-1).
duration_secondsintegerDuration in seconds.
Allowed values:3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
enable_soundbooleanEnable sound generation.
first_frame_image_urlstringFirst frame image URL.
kling_elementsarrayElement references with image, video, or audio materials.
last_frame_image_urlstringLast frame image URL for single-shot mode.
modelstringModel slug.
multi_promptarrayPrompt segments for multi-shot mode.
multi_shotsbooleanEnable multi-shot generation.
negative_promptstringNegative prompt.
output_resolutionstringOutput resolution.
Allowed values:720p, 1080p, 4k
promptstringVideo description. Required unless multi_shots is enabled.
kling-o111 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
Default: 16:9
callback_urlstringWebhook URL for async notifications.
duration_secondsintegerDuration in seconds.
Allowed values:5
Default: 5
enable_soundbooleanSound generation must remain disabled.
Default:false
modestringGeneration mode.
Allowed values:std, pro
Default: std
modelstringModel slug.
preserve_reference_video_audiobooleanPreserve the reference video's original audio.
Default:false
promptstringVideo description; reference media with matching numbered markers.
Range:1 - 2500
reference_image_urlsarrayOrdered public HTTP(S) JPG, JPEG, or PNG reference image URLs.
reference_video_typestringUse the video as a base edit or feature reference.
Allowed values:base, feature
Default: base
reference_video_urlstringPublic HTTP(S) MP4 or MOV reference video URL.
kling-v2.1-master-text-to-video8 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
callback_urlstringWebhook URL for async notifications.
cfg_scalenumberGuidance scale (0-1).
duration_secondsintegerDuration in seconds.
Allowed values:5, 10
enable_soundbooleanEnable sound generation.
modelstringModel slug.
negative_promptstringNegative prompt.
promptstringVideo description.
kling-v2.5-turbo-text-to-video-pro8 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
callback_urlstringWebhook URL for async notifications.
cfg_scalenumberGuidance scale (0-1).
duration_secondsintegerDuration in seconds.
Allowed values:5, 10
enable_soundbooleanEnable sound generation.
modelstringModel slug.
negative_promptstringNegative prompt.
promptstringVideo description.
kling-v2.67 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
Default: 16:9
callback_urlstringWebhook URL for async notifications.
duration_secondsintegerDuration in seconds.
Allowed values:5, 10
Default: 5
enable_soundbooleanEnable sound generation; requires pro mode.
Default:false
modestringGeneration mode.
Allowed values:std, pro
Default: std
modelstringModel slug.
promptstringVideo description.
Range:1 - 2500
kling-v3-omni7 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
Default: 16:9
callback_urlstringWebhook URL for async notifications.
duration_secondsintegerDuration in seconds.
Allowed values:3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Default: 5
enable_soundbooleanEnable synchronized sound generation.
Default:false
modelstringModel slug.
output_resolutionstringOutput resolution.
Allowed values:720p, 1080p, 4k
Default: 720p
promptstringVideo description.
Range:1 - 2500
kling-v3-turbo-text-to-video6 fields
aspect_ratiostringOutput aspect ratio.
Allowed values:16:9, 9:16, 1:1
Default: 16:9
callback_urlstringWebhook URL for async notifications.
duration_secondsintegerDuration in seconds.
Allowed values:3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Default: 5
modelstringModel slug.
output_resolutionstringOutput resolution.
Allowed values:720p, 1080p
Default: 720p
promptstringVideo description.
Range:1 - 2500
Create acceptance
POST /api/v1/kling/text_to_video
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "processing"
}
Polling processing
GET /api/v1/kling/text_to_video/:id
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "processing"
}
Polling completed
GET /api/v1/kling/text_to_video/:id
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "completed",
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
Polling failed
GET /api/v1/kling/text_to_video/:id
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"error": "Task processing failed.",
"id": "tsk_reference_demo",
"status": "failed"
}
Customer callback: completed
POST callback_url
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "completed",
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
Customer callback: failed
POST callback_url
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"error": {
"code": "generation_failed",
"message": "Task processing failed."
},
"id": "tsk_reference_demo",
"status": "failed"
}
Errors
{
"error": {
"code": "invalid_request",
"message": "A required request field is missing."
}
}
Generated Code Samples
Use cURL directly, or install an SDK for your language. Each sample submits the validated request shown in this reference.
curl -X POST https://runapi.ai/api/v1/kling/text_to_video \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"model":"kling-v3-turbo-text-to-video","prompt":"A paper kite flying above a quiet coastal town at sunrise","duration_seconds":5,"aspect_ratio":"16:9","output_resolution":"720p"}'
Install
npm install @runapi.ai/kling
import { KlingClient } from "@runapi.ai/kling";
const client = new KlingClient({ apiKey: process.env.RUNAPI_API_KEY });
const task = await client.textToVideo.create({
"model": "kling-v3-turbo-text-to-video",
"prompt": "A paper kite flying above a quiet coastal town at sunrise",
"duration_seconds": 5,
"aspect_ratio": "16:9",
"output_resolution": "720p"
});
Install
pip install runapi-kling
import os
from runapi.kling import KlingClient
client = KlingClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_video.create(
model="kling-v3-turbo-text-to-video",
prompt="A paper kite flying above a quiet coastal town at sunrise",
duration_seconds=5,
aspect_ratio="16:9",
output_resolution="720p"
)
Install
go get github.com/runapi-ai/kling-sdk/go@latest
package main
import (
"context"
"log"
"os"
"github.com/runapi-ai/core-sdk/go/option"
kling "github.com/runapi-ai/kling-sdk/go/kling"
)
func main() {
client, err := kling.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
if err != nil {
log.Fatal(err)
}
_, err = client.TextToVideo.Create(context.Background(), kling.TextToVideoParams{
Model: "kling-v3-turbo-text-to-video",
Prompt: "A paper kite flying above a quiet coastal town at sunrise",
DurationSeconds: 5,
AspectRatio: "16:9",
OutputResolution: "720p",
})
if err != nil {
log.Fatal(err)
}
}
Install
gem install runapi-kling
client = RunApi::Kling::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
task = client.text_to_video.create(
model: "kling-v3-turbo-text-to-video",
prompt: "A paper kite flying above a quiet coastal town at sunrise",
duration_seconds: 5,
aspect_ratio: "16:9",
output_resolution: "720p"
)
Install
implementation("ai.runapi:runapi-kling")
import ai.runapi.core.polling.TaskCreateResponse;
import ai.runapi.kling.KlingClient;
import ai.runapi.kling.types.TextToVideoParams;
KlingClient client = KlingClient.builder()
.apiKey(System.getenv("RUNAPI_API_KEY"))
.build();
TaskCreateResponse task = client.textToVideo().create(
TextToVideoParams.builder()
.model("kling-v3-turbo-text-to-video")
.prompt("A paper kite flying above a quiet coastal town at sunrise")
.durationSeconds(5)
.aspectRatio("16:9")
.outputResolution("720p")
.build()
);
Install
composer require runapi-ai/kling
<?php
use RunApi\Core\ClientOptions;
use RunApi\Kling\KlingClient;
$client = new KlingClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$task = $client->textToVideo->create([
"model" => "kling-v3-turbo-text-to-video",
"prompt" => "A paper kite flying above a quiet coastal town at sunrise",
"duration_seconds" => 5,
"aspect_ratio" => "16:9",
"output_resolution" => "720p"
]);