Kling AI Video Generator API documentation
Generate videos with Kling AI Video Generator (Kuaishou Kling AI). Supports both text and image input modes.
Endpoints
| Contract item | Value |
|---|---|
| Capability | kling-ai-video-generator |
| Submit | POST https://vidmage.ai/api/v1/kling-ai-video-generator/submit |
| Query | POST https://vidmage.ai/api/v1/kling-ai-video-generator/query |
| Task identifier | taskId |
| Result field | videoUrl |
Authenticate with Authorization: Bearer YOUR_API_KEY. Save the task identifier and query the same capability. Use a stable Idempotency-Key for submission retries.
Product guide: Kling API
Parameters and input rules
| Field | Type | Required | Default | Meaning and limits |
|---|---|---|---|---|
prompt | string | Yes | Not specified | Text prompt describing the video to generate (max 2500 chars). Minimum characters: 1Maximum characters: 2500 |
imageUrl | string | No | Not specified | Optional input image URL. When provided, the task runs in image-to-video mode. In that mode, output ratio is inferred from the input image. |
lastFrameUrl | string | No | Not specified | Optional public URL for the final frame in image-to-video mode. |
duration | string | No | "5" | Video duration in seconds. Values: "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" |
aspectRatio | string | No | "16:9" | Output aspect ratio for modes that expose a ratio parameter. Ignored when imageUrl selects a mode whose ratio is inferred from the input image. Values: "16:9", "9:16", "1:1" |
sound | boolean | No | true | Generate synchronized audio along with the video. Enabling sound adds a per-second credit surcharge. |
negativePrompt | string | No | "Flickering, blur, distorted limbs, watermark, low resolution." | Describe unwanted video content or artifacts. Minimum characters: 0Maximum characters: 2500 |
cfgScale | number | No | 0.5 | Prompt guidance strength. Minimum: 0Maximum: 1Multiple of: 0.1 |
multiShot | boolean | No | false | Generate a video composed of multiple shots. |
shotType | string | No | "customize" | Use custom or automatically planned shot structure. Values: "customize", "intelligence" |
multiPrompt | string[] | No | [] | Additional prompts for complex multi-shot compositions. Maximum items: 6 |
elementList | string[] | No | [] | Element references to preserve across the generated shot. Maximum items: 3 |
text to video
These are public VidMage field names. The server maps them to provider fields. Input media selects the mode; use its limits together with the parameter table.
| Control | Mode-specific rule |
|---|---|
prompt | Required; 1–2500 characters. |
duration | JSON string. Values: "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15". Default: 5. |
aspectRatio | Values: "16:9", "9:16", "1:1". Default: 16:9. |
resolution | Not used in this mode. |
sound | Boolean. Default: true. |
negativePrompt | Describe unwanted video content or artifacts. Minimum characters: 0Maximum characters: 2500Default: "Flickering, blur, distorted limbs, watermark, low resolution." |
cfgScale | Prompt guidance strength. Minimum: 0Maximum: 1Multiple of: 0.1Default: 0.5 |
multiShot | Generate a video composed of multiple shots. Default: false |
shotType | Use custom or automatically planned shot structure. Values: "customize", "intelligence"Default: "customize" |
multiPrompt | Additional prompts for complex multi-shot compositions. Maximum items: 6Default: [] |
image to video
These are public VidMage field names. The server maps them to provider fields. Input media selects the mode; use its limits together with the parameter table.
| Control | Mode-specific rule |
|---|---|
prompt | Required; 1–2500 characters. |
duration | JSON string. Values: "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15". Default: 5. |
aspectRatio | Not used in this mode. |
resolution | Not used in this mode. |
sound | Boolean. Default: true. |
imageUrl | Formats: jpg, png. |
lastFrameUrl | Optional final-frame image. |
negativePrompt | Describe unwanted video content or artifacts. Minimum characters: 0Maximum characters: 2500 |
cfgScale | Prompt guidance strength. Minimum: 0Maximum: 1Multiple of: 0.1Default: 0.8 |
multiShot | Generate a video composed of multiple shots. Default: false |
shotType | Use custom or automatically planned shot structure. Values: "customize", "intelligence"Default: "customize" |
multiPrompt | Additional prompts for complex multi-shot compositions. Maximum items: 6Default: [] |
elementList | Element references to preserve across the generated shot. Maximum items: 3Default: [] |
Example request
{
"prompt": "A cinematic tracking shot follows a cyclist through a quiet forest as morning fog drifts between the trees",
"duration": "5",
"aspectRatio": "16:9",
"sound": true,
"negativePrompt": "Flickering, blur, distorted limbs, watermark, low resolution.",
"cfgScale": 0.5,
"multiShot": false,
"shotType": "customize"
}# Set VIDMAGE_IDEMPOTENCY_KEY to a unique value for this task; preserve it for transport retries.
curl -X POST "https://vidmage.ai/api/v1/kling-ai-video-generator/submit" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: ${VIDMAGE_IDEMPOTENCY_KEY}" \
-H "Content-Type: application/json" \
-d '{"prompt":"A cinematic tracking shot follows a cyclist through a quiet forest as morning fog drifts between the trees","duration":"5","aspectRatio":"16:9","sound":true,"negativePrompt":"Flickering, blur, distorted limbs, watermark, low resolution.","cfgScale":0.5,"multiShot":false,"shotType":"customize"}'
# -> { "success": true, "taskId": "...", "creditsConsumed": ... }Task results and recovery
URL of the generated video. Read videoUrl from the completed query response. Preserve taskId while the task is running.
curl -X POST "https://vidmage.ai/api/v1/kling-ai-video-generator/query" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "taskId": "TASK_ID_FROM_SUBMIT" }'
# -> { "success": true, "data": { "status": "...", "videoUrl": "https://..." } }Submission and task queries report the available task and usage information. A timeout is not a confirmed failure. Recover the existing task instead of resubmitting.
For face selection and error recovery, follow Task lifecycle. MCP uses the normalized taskId argument in get_task_result, including capabilities whose REST identifier is requestId.
Credits
| Component / option | Rate | Minimum |
|---|---|---|
| Base rate | 20 credits / second | — |
Base charge = duration × the selected resolution rate.
Sound adds 5 credits per second before option multipliers.
Use the Playground or the MCP credit estimator for your exact inputs. Credits and billing.
