Kling 4.0 Text to Video
kwaivgi/kling-v4.0/text-to-video
Generate 3–30 second videos from a prompt with synchronized audio, in 720p or 1080p.
Examples
Parameters
| Name | Type | Default | Constraints | Description |
|---|---|---|---|---|
| prompt *Prompt | textarea | — | ≤ 5000 chars | The positive prompt for the generation. |
| resolutionResolution | select | 720p | 720p | 1080p | Output resolution. |
| durationDuration | select | 5 | 3 ~ 30 · step 1 · 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | … | The duration of the generated video in seconds (3-30). |
| aspect_ratioAspect ratio | select | 16:9 | 16:9 | 9:16 | 1:1 | 21:9 | Output video aspect ratio. |
Output fields
| Field | Type | Description |
|---|---|---|
| videos | array<string> | Generated video URLs. |
API
Call this model through one unified REST API. Get a key on the API Keys page.
cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/text-to-video" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
}'
# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
-H "Authorization: Bearer YOUR_API_KEY"Python
import time, requests
API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# 1) Submit
resp = requests.post(
"https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/text-to-video",
headers=HEADERS,
json={
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
},
)
resp.raise_for_status() # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()
# 2) Poll until a terminal state (completed / failed / cancelled).
# This model is allowed up to 1800s server-side.
deadline = time.time() + 1860
while task.get("status") not in ("completed", "failed", "cancelled"):
if time.time() > deadline:
raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
time.sleep(3)
poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
poll.raise_for_status()
task = poll.json()
print(task["status"], task.get("output"))JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };
// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/text-to-video", {
method: "POST",
headers: { ...HEADERS, "Content-Type": "application/json" },
body: JSON.stringify({
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
}),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();
// 2) Poll until a terminal state (completed / failed / cancelled).
// This model is allowed up to 1800s server-side.
const deadline = Date.now() + 1860 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
await new Promise((r) => setTimeout(r, 3000));
const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
task = await poll.json();
}
console.log(task.status, task.output);Documentation
Kling 4.0 · Text to Video
Generate a 3–30 second video from a text prompt, with synchronized stereo audio. Describe subjects, action, camera movement and desired sound in the prompt.
Inputs
- prompt: string, required.
- resolution: "720p" (default) or "1080p".
- duration: integer from 3 through 30, default 5.
- aspect_ratio: "16:9" (default), "9:16", "1:1" or "21:9".
Limits and references
No image, video or audio-reference input is supported on this endpoint. Native audio is included; there is no sound switch.
List price and initial credit charge
720p: $0.157 per output second. 1080p: $0.235 per output second.
Cost = output seconds × resolution rate. A 5-second clip costs $0.785 at 720p or $1.175 at 1080p.
1 USD = 100 Nami credits. Round the total charge upward to 0.01 credit: credits = ceil(cost_usd × 10000) / 100. These are list prices; no promotional discount is applied.
MaaS mapping
prompt, resolution, duration and aspect_ratio pass to MaaS with the same names and types.
Nami API
Send a POST request with Authorization: Bearer YOUR_NAMI_API_KEY and Content-Type: application/json to:
https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/text-to-video
Example request body:
{
"input": {
"prompt": "A small sailboat crosses a quiet lake at sunrise. Slow lateral tracking shot, gentle water sounds and distant birds.",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
}
Replace example.com URLs with publicly accessible media URLs. Use the returned task_uuid to poll GET https://www.namifusion.com/api/v1/marketplace/run/tasks/{task_uuid} with the same authorization. On success, read generated video URLs from output.videos.
Related models
xAI Grok Imagine Video v1.5 Text to Video
Generate 1-15 second videos from text prompts at 480p, 720p, or 1080p.
MiniMax H3 Text to Video
MiniMax H3 Text to Video generates coherent 2K videos from text prompts, with flexible 4-15 second duration and six selectable aspect ratios for cinematic scenes, creative videos, and production workflows. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
ltx-2.5/text-to-video
LTX 2.5 Text-to-Video generates high-fidelity synchronized audio-video content from text prompts, with flexible duration and 720P / 1080P / 2K / 4K output for cinematic videos, social content, ads, and production workflows. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Kling Omni Video O3 Standard Text-To-Video
Kling Omni Video O3 is Kuaishou's advanced unified multi-modal video model with MVL (Multi-modal Visual Language) technology. Text-to-Video mode generates cinematic videos from text prompts with subject consistency, natural physics simulation, and precise semantic understanding. Supports audio generation. Ready-to-use REST API, best performance, no coldstarts, affordable pricing.
Kling 3.0
Kling 3.0 delivers high-quality text-to-video generation with smooth motion, cinematic visuals, accurate prompt adherence, and native audio for ready-to-share clips. Ready-to-use REST inference API, best performance, no cold starts, affordable pricing.
Kling V2.6 Text to Video API
Kling 2.6 delivers top-tier text-to-video generation with smooth motion, cinematic visuals, strong prompt adherence, and native audio for ready-to-share clips. Ready-to-use REST inference API, best performance, no cold starts, affordable pricing.
Gemini Omni Flash Text to Video API
Gemini Omni Flash Text to Video creates short AI videos with synchronized audio from text prompts, combining visual generation and audio output for fast multimodal video creation. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Seedance 2.0 Mini Text to Video
Seedance 2.0 Mini Text to Video is ByteDance's faster, lower-cost text-to-video model for cinematic multi-shot videos. It generates narrative sequences from text prompts with AI camera control, consistent characters across scenes, 480P / 720P / 1080P / 4K output, 4-15s duration, and flexible aspect ratios. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.