Create Video From Text
April 18, 2025
Table of contents
This endpoint generates a video based on a text prompt.
https://api.useapi.net/v1/kling/videos/text2video
Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
API token
is required, see Setup useapi.net for details.
Request Body
{
"email": "[email protected]",
"prompt": "A majestic mountain landscape with snow-capped peaks and flowing rivers",
"negative_prompt": "people, buildings, text, low quality",
"cfg_scale": 0.5,
"duration": "5",
"model_name": "kling-v1-6",
"aspect_ratio": "16:9",
"mode": "pro",
"replyUrl": "https://your-callback-url.com/webhook",
"replyRef": "your-reference-id"
}
-
email
is optional when only one account configured.
However, if you have multiple accounts configured, this parameter becomes required. -
prompt
is required, the text description of the video to generate.
Maximum length: 2500 characters. -
negative_prompt
is optional, what not to include in the generated video.
Maximum length: 2500 characters. -
cfg_scale
is optional, guidance scale for text-to-video generation.
Range:0
to1
. Default:0.5
. -
duration
is optional, length of the video in seconds.
Options:5
(default) or10
. -
model_name
is optional, the AI model version to use.
Options:kling-v1-5
,kling-v1-6
(default),kling-v2-0
. -
aspect_ratio
is optional, the video aspect ratio.
Options:16:9
(default),9:16
,1:1
. -
mode
is optional, quality level.
Options:std
(standard, default) orpro
(higher quality, slower generation). -
maxJobs
is optional, range from1
to10
.
Specifies the maximum number of concurrent jobs. -
replyUrl
is optional, a callback URL to receive results when completed. -
replyRef
is optional, a reference identifier for the callback.
Note: When using model_name kling-v2-0
, the parameters cfg_scale
, duration
, mode
, and camera_control_enabled
are not supported.
Responses
-
{ "id": 12345678, "created": 1712345678000, "status": "submitted", "status_final": false, "type": "m2v_txt2video_hq", "taskInfo": { "arguments": [ { "name": "prompt", "value": "A majestic mountain landscape with snow-capped peaks and flowing rivers" }, { "name": "negative_prompt", "value": "people, buildings, text, low quality" }, { "name": "cfg", "value": 0.5 }, { "name": "duration", "value": "5" }, { "name": "kling_version", "value": "1.6" }, { "name": "aspect_ratio", "value": "16:9" } ] }, "scheduled": true }
-
{ "error": "Parameter prompt is required" }
-
{ "error": "Unauthorized", "code": 401 }
When successful, the response includes a task ID which can be used to check the status using GET /tasks/{task_id}.
Model
{ // TypeScript, all fields are optional
id: number // Task ID
created: number // Creation timestamp in milliseconds
status: string // Task status: "submitted", "processing", "failed", or "succeed"
status_final: boolean // Whether this is the final status of the task
type: string // Task type ("m2v_txt2video" or "m2v_txt2video_hq")
taskInfo: {
arguments: Array<{
name: string // Argument name
value: string // Argument value
}>
}
scheduled: boolean // Whether the task is scheduled
}
Examples
-
curl -X POST "https://api.useapi.net/v1/kling/videos/text2video" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer …" \ -d '{ "email": "[email protected]", "prompt": "A majestic mountain landscape with snow-capped peaks and flowing rivers", "negative_prompt": "people, buildings, text, low quality", "model_name": "kling-v1-6", "aspect_ratio": "16:9", "mode": "pro" }'
-
const token = "API token"; const email = "Previously configured account email"; const apiUrl = "https://api.useapi.net/v1/kling/videos/text2video"; const response = await fetch(apiUrl, { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: JSON.stringify({ email: email, prompt: "A majestic mountain landscape with snow-capped peaks and flowing rivers", negative_prompt: "people, buildings, text, low quality", model_name: "kling-v1-6", aspect_ratio: "16:9", mode: "pro" }) }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" email = "Previously configured account email" apiUrl = "https://api.useapi.net/v1/kling/videos/text2video" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } data = { "email": email, "prompt": "A majestic mountain landscape with snow-capped peaks and flowing rivers", "negative_prompt": "people, buildings, text, low quality", "model_name": "kling-v1-6", "aspect_ratio": "16:9", "mode": "pro" } response = requests.post(apiUrl, headers=headers, json=data) print(response, response.json())