Kling Video
Kling Video uses an asynchronous video task API. Create a task first, then poll the task endpoint for status and the final video URL.
Endpoints
Unified Video API
| Capability | Method | Path |
|---|---|---|
| Create video task | POST | /v1/video/generations |
| Retrieve video task | GET | /v1/video/generations/{task_id} |
Kling-Compatible API
| Capability | Method | Path |
|---|---|---|
| Text to video | POST | /kling/v1/videos/text2video |
| Image to video | POST | /kling/v1/videos/image2video |
| Retrieve text-to-video task | GET | /kling/v1/videos/text2video/{task_id} |
| Retrieve image-to-video task | GET | /kling/v1/videos/image2video/{task_id} |
Every request requires an API key:
http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonModels
| Model |
|---|
kling-v3 |
Actual availability depends on your account permissions.
Unified API Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Kling model name |
prompt | string | Yes | Video generation prompt |
image | string | No | First-frame image URL. When provided, the request is handled as image-to-video |
mode | string | No | Generation mode, such as std or pro. Defaults to std |
duration | number | No | Video duration in seconds. Defaults to 5 |
size | string | No | Size used to infer aspect ratio, such as 1920x1080, 1080x1920, 1024x1024 |
metadata | object | No | Kling-specific options |
metadata Fields
metadata is passed through as Kling request fields. Common fields:
| Field | Type | Description |
|---|---|---|
negative_prompt | string | Negative prompt |
aspect_ratio | string | Aspect ratio, such as 16:9, 9:16, 1:1 |
image_tail | string | Last-frame image URL |
cfg_scale | number | Prompt relevance |
camera_control | object | Camera control |
static_mask | string | Static mask |
dynamic_masks | object[] | Dynamic masks |
callback_url | string | Callback URL |
external_task_id | string | Client-defined task ID |
Text to Video
bash
curl -X POST https://cubicspaces.cloud/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "kling-v3",
"prompt": "A cinematic shot of a futuristic cubic city at sunrise, slow camera movement, realistic lighting",
"mode": "std",
"duration": 5,
"size": "1920x1080",
"metadata": {
"aspect_ratio": "16:9",
"negative_prompt": "blur, distortion, low quality"
}
}'Image to Video
bash
curl -X POST https://cubicspaces.cloud/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "kling-v3",
"prompt": "Animate the product from the first frame with a slow clockwise rotation, keep the product shape stable",
"image": "https://example.com/first-frame.png",
"mode": "std",
"duration": 5,
"metadata": {
"aspect_ratio": "16:9",
"negative_prompt": "deformation, flicker"
}
}'First and Last Frame
bash
curl -X POST https://cubicspaces.cloud/v1/video/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "kling-v3",
"prompt": "Create a smooth transition from the first frame to the last frame",
"image": "https://example.com/first-frame.png",
"duration": 5,
"metadata": {
"image_tail": "https://example.com/last-frame.png",
"aspect_ratio": "16:9"
}
}'Camera Control Example
json
{
"model": "kling-v3",
"prompt": "A slow push-in shot toward the product on a clean studio table",
"image": "https://example.com/product.png",
"duration": 5,
"metadata": {
"aspect_ratio": "16:9",
"camera_control": {
"type": "simple",
"config": {
"zoom": 1.2,
"horizontal": 0,
"vertical": 0
}
}
}
}Kling-Compatible API Examples
Use the compatible paths if you prefer a Kling-like request format.
Text to Video
bash
curl -X POST https://cubicspaces.cloud/kling/v1/videos/text2video \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "kling-v3",
"prompt": "A cinematic aerial shot of a futuristic cubic city",
"mode": "std",
"duration": 5,
"aspect_ratio": "16:9",
"negative_prompt": "blur, distortion"
}'Image to Video
bash
curl -X POST https://cubicspaces.cloud/kling/v1/videos/image2video \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "kling-v3",
"prompt": "Animate the subject naturally while preserving the first-frame composition",
"image": "https://example.com/first-frame.png",
"mode": "std",
"duration": 5,
"aspect_ratio": "16:9"
}'Create Response
A successful unified create request returns a video task object:
json
{
"id": "video_xxx",
"task_id": "video_xxx",
"object": "video",
"model": "kling-v3",
"status": "queued",
"progress": 0,
"created_at": 1770000000
}Use either id or task_id to retrieve the task.
Retrieve Task
bash
curl https://cubicspaces.cloud/v1/video/generations/video_xxx \
-H "Authorization: Bearer YOUR_API_KEY"Retrieve Response
json
{
"id": "video_xxx",
"task_id": "video_xxx",
"object": "video",
"model": "kling-v3",
"status": "completed",
"progress": 100,
"seconds": "5",
"created_at": 1770000000,
"completed_at": 1770000120,
"metadata": {
"url": "https://example.com/output.mp4"
}
}Status Values
| status | Description |
|---|---|
queued | The task is queued |
in_progress | The task is running |
completed | The task has completed |
failed | The task failed |
When the task is completed, read the video URL from metadata.url.