Kling 4.0 Text to Video API
kwaivgi/kling-v4.0/text-to-videoKling 4.0 Text to Video turns a prompt or multi-shot script into one 3–30 second 720p or 1080p video with stereo audio and five aspect ratios. It keeps scenes coherent across long takes and shot changes while following your camera, dialogue and sound directions.
Switch to JSON to write multi-shot prompts with multi_prompt.
REST API
Quick Start
Make your first Kling 4.0 Text to Video request in three steps. The example asks for a 10-second take with dialogue and returns a task_id.
Connect to the Vidgo API
Create an API key, keep it on your server, and send it in the Authorization header as a Bearer token.
- Endpoint
- POST
https://api.vidgo.ai/api/generate/submit - Authentication
- Authorization: Bearer VIDGO_API_KEY
Submit one generation task
Run the short example with a prompt. Duration, resolution and aspect_ratio have defaults.
curl --request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "kwaivgi/kling-v4.0/text-to-video",
"input": {
"prompt": "A single unbroken 10-second shot in a night market after rain. A street cook in a grey apron tosses noodles in a flaming wok, then slides them onto a plate and pushes it across the counter toward the camera. Camera: slow handheld push from the crowd to the counter, keeping the cook's face and hands in focus. Lighting: warm bulbs reflected in wet pavement, drifting steam. Audio: sizzling wok, clattering ladle, low crowd chatter; the cook says in English, \"Careful, it's hot.\" No text, no logos, no watermark.",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}'Wait for the result
Use the returned task_id to check the same task until it reaches finished or failed. On success, read data.files[].file_url.
Track status
GET https://api.vidgo.ai/api/generate/status/{task_id}Poll every few seconds while the status is not_started or running, and stop on finished or failed. On success, read data.files[].file_url. For longer clips, lengthen the interval gradually or add callback_url to the submit request.
not_startedrunningfinishedfailed{
"code": 200,
"data": {
"task_id": "FYVDHUJZQ3J0SH2O",
"status": "not_started",
"created_time": "2026-11-05T07:04:47"
}
}{
"code": 200,
"data": {
"task_id": "FYVDHUJZQ3J0SH2O",
"status": "finished",
"files": [
{
"file_url": "https://cdn.vidgo.ai/apis/models/kwaivgi/kling-v4.0/text-to-video/v2/01/output-01.mp4",
"file_type": "video"
}
],
"created_time": "2026-11-05T07:04:47",
"error_message": null,
"progress": 100
}
}Complete runnable example
Open this after the three-step flow is clear. It combines submission, polling, terminal-state handling and result extraction in one script.
set -euo pipefail
: "${VIDGO_API_KEY:?Set VIDGO_API_KEY in your environment}"
REQUEST_BODY=$(cat <<'JSON'
{
"model": "kwaivgi/kling-v4.0/text-to-video",
"input": {
"prompt": "A single unbroken 10-second shot in a night market after rain. A street cook in a grey apron tosses noodles in a flaming wok, then slides them onto a plate and pushes it across the counter toward the camera. Camera: slow handheld push from the crowd to the counter, keeping the cook's face and hands in focus. Lighting: warm bulbs reflected in wet pavement, drifting steam. Audio: sizzling wok, clattering ladle, low crowd chatter; the cook says in English, \"Careful, it's hot.\" No text, no logos, no watermark.",
"duration": 10,
"resolution": "720p",
"aspect_ratio": "16:9"
}
}
JSON
)
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
--request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY")
TASK_ID=$(printf '%s' "$SUBMIT_RESPONSE" | jq -r '.data.task_id // .task_id // empty')
if [ -z "$TASK_ID" ]; then
printf 'Submit response did not include task_id:
%s
' "$SUBMIT_RESPONSE" >&2
exit 1
fi
while true; do
STATUS_RESPONSE=$(curl --silent --show-error --fail-with-body \
--url "https://api.vidgo.ai/api/generate/status/$TASK_ID" \
--header "Authorization: Bearer $VIDGO_API_KEY")
STATUS=$(printf '%s' "$STATUS_RESPONSE" | jq -r '.data.status // .status // empty')
case "$STATUS" in
finished)
printf '%s' "$STATUS_RESPONSE" | jq -r '(.data.files // .files // [])[]?.file_url'
break
;;
failed)
printf '%s' "$STATUS_RESPONSE" | jq -r '.data.error_message // .error_message // "Generation failed"' >&2
exit 1
;;
not_started|running)
sleep 2
;;
*)
printf 'Unexpected task status: %s
' "$STATUS" >&2
exit 1
;;
esac
doneRequest Parameters
model and callback_url belong at the request root; generation parameters belong inside input.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | — | Fixed to kwaivgi/kling-v4.0/text-to-video. |
| callback_url | string (URL) | No | — | A public HTTP(S) URL that receives the task result when it finishes. |
| input | object | Yes | — | Generation parameters: prompt or multi_prompt, plus optional duration, resolution and aspect_ratio. |
| input.prompt | string | No | — | Single prompt, 1–26,000 characters. Exactly one of prompt or multi_prompt. |
| input.multi_prompt | object[] | No | — | Shots of {prompt, duration?}; totals 3–30 s. If duration is also sent it must equal the total. |
| input.duration | integer | No | 5 | 3–30 s. |
| input.resolution | string | No | 720p | 720p or 1080p. |
| input.aspect_ratio | string | No | auto | auto, 16:9, 9:16, 1:1, 21:9. |
Response Fields
Submission returns the task identity immediately. Status responses add progress, output files or a failure message as the task advances.
| Field | Type | Description |
|---|---|---|
| code | integer | Application result code. Successful responses use 0 or 200. |
| message | string | Human-readable response or error message when present. |
| data.task_id | string | Task identifier used in the status endpoint path. |
| data.status | string | Current state: not_started, running, finished or failed. |
| data.created_time | string | Task creation time in date-time format. |
| data.progress | number | Completion percentage when the provider reports progress. |
| data.files[] | array | Generated output files returned after a successful task. |
| data.files[].file_url | string | Public URL of the generated video. |
| data.files[].file_type | string | Generated file type, such as video. |
| data.files[].watermark_url | string | null | Watermarked output URL when one is available. |
| data.error_message | string | null | Failure detail when status is failed. |
Task Lifecycle
Treat not_started and running as non-terminal states. finished and failed are terminal; stop polling when either is returned.
not_startedThe task has been accepted and is queued to start.
runningThe video is being generated. Keep polling the status endpoint.
finishedThe task is complete. Read the video URL from data.files[].file_url.
failedGeneration failed. Read data.error_message for details and stop polling.
Polling and Errors
- Authentication401 means the Bearer API key is missing or invalid. Check your key in the dashboard before retrying.
- Validation400 means a request field is invalid or belongs to another endpoint. Check that exactly one of prompt or multi_prompt is sent.
- Polling intervalPoll every few seconds while the task runs, and lengthen the interval gradually for longer clips.
- Terminal statesPoll only while the status is not_started or running. Stop on finished or failed.
- Callback optionAdd callback_url at the request root to receive the final result without continuous polling.
Model Specifications
| Specification | Value | Description |
|---|---|---|
| Model | kwaivgi/kling-v4.0/text-to-video | Model identifier for asynchronous text-to-video generation. |
| Duration | 3–30 | Whole seconds; defaults to 5. |
| Resolution | 720p | 1080p | Defaults to 720p. |
| Aspect ratio | auto | 16:9 | 9:16 | 1:1 | 21:9 | Defaults to auto. |
| Pricing | 28.5 / 42.5 credits/s | 720p / 1080p, per output second. |
Related Models
Kling 4.0 Text to Video API FAQ
What is the Kling 4.0 Text to Video API?
Kling 4.0 Text to Video is a Kuaishou model for generating video from text, released by Kling AI on 15 October 2026. It turns one prompt or a multi-shot script into a 3–30 second clip at 720p or 1080p with a stereo audio track. Single-pass generation up to 30 seconds keeps characters, setting and camera direction coherent across long takes and shot changes. You can call it programmatically or try it from the playground above.
How do multi-shot prompts work in Kling 4.0 Text to Video?
Send multi_prompt instead of prompt: a list of shots, each with its own prompt of up to 512 characters and a duration of 1–30 seconds (5 by default). The shot durations must total 3–30 seconds, and that total becomes the clip length.
How long can a Kling 4.0 Text to Video clip be?
Any whole number of seconds from 3 to 30, generated in a single pass. The default is 5 seconds.
Does Kling 4.0 Text to Video generate dialogue and sound?
Every clip includes a stereo audio track. Write spoken lines in quotes, name the language, and describe effects and ambience; Kling lists English, Chinese, Japanese, Korean, Spanish and other languages for dialogue.
How much does Kling 4.0 Text to Video cost?
It costs 28.5 credits ($0.1425) per output second at 720p and 42.5 credits ($0.2125) at 1080p. A 10-second 1080p clip is 425 credits.
Which aspect ratios does Kling 4.0 Text to Video offer?
auto, 16:9, 9:16, 1:1 and 21:9. Set the ratio explicitly when you deliver to a fixed format such as a vertical feed.
How does Kling 4.0 Text to Video compare with Kling 3.0 Turbo?
Kling 4.0 extends single clips to 30 seconds, adds multi-shot prompts of up to 30 seconds and offers both 720p and 1080p. Kling 3.0 Turbo Pro remains a faster, lower-cost 1080p option for clips up to 15 seconds.















