Text to Video
Create a Kling-compatible text-to-video task.
Create Task
Request
http
POST /v1/videos/text2video| Field | Type | Required | Supported values and limits | Description |
|---|---|---|---|---|
model_name | string | Yes | kling-v2-5-turbo, kling-v3 | Model name. kling-v2-5-turbo is suited for basic text-to-video, while kling-v3 supports longer durations and multi-shot generation. |
prompt | string | No | Up to 2500 chars | Required for kling-v2-5-turbo. Under kling-v3, it is required when multi_shot=false and is used to describe subject, action, scene, camera language, and style; when multi_shot=true, this field is ignored. |
multi_shot | boolean | No | Only kling-v3; true, false | Enables multi-shot generation. Default is false. When multi_shot=true, prompt is ignored; when multi_shot=false, shot_type and multi_prompt are ignored. kling-v2-5-turbo does not support this field. |
shot_type | string | No | Only kling-v3; only customize is supported | Required when multi_shot=true; ignored when multi_shot=false. Only custom storyboards are supported. intelligence is not supported. |
multi_prompt | array | No | Only kling-v3; 1 to 6 items | Required when multi_shot=true and shot_type=customize; ignored when multi_shot=false. Used to define prompt and duration for each shot. |
multi_prompt[].index | integer | Yes | Only kling-v3 | Shot index. Using 1,2,3... in order is recommended. |
multi_prompt[].prompt | string | Yes | Only kling-v3; up to 512 chars | Prompt for the current shot, including subject, action, scene, camera setup, or style. |
multi_prompt[].duration | string | Yes | Only kling-v3; at least 1 second | Duration of the current shot. The sum of all shot durations must equal the total duration. |
negative_prompt | string | No | Up to 2500 chars | Negative prompt used to restrict unwanted content, style, or artifacts. |
sound | string | No | Only kling-v3; on, off | Whether to generate audio together with the video. Default is off. kling-v2-5-turbo does not support this field. |
mode | string | No | std, pro | Generation mode. std is the standard, more cost-effective mode. pro is the higher-quality mode. 4k is not supported. |
aspect_ratio | string | No | 16:9, 9:16, 1:1 | Output frame aspect ratio. Default is 16:9. |
duration | string | No | kling-v2-5-turbo: 5, 10; kling-v3: 3 to 15 | Total video duration in seconds. In multi-shot mode, the sum of all multi_prompt[].duration values must equal this value. |
watermark_info | object | No | {"enabled": boolean} | Whether to return a watermarked result in parallel. |
external_task_id | string | No | Custom string | Custom task ID for later query use. It must be unique within the same account. |
Response
json
{
"code": 0,
"message": "success",
"request_id": "req_abc123",
"data": {
"task_id": "sg_vid_xxxxxxxx",
"task_status": "submitted",
"created_at": 1776209922,
"updated_at": 1776209922
}
}Example
Basic Example
bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video" \
-H "Authorization: Bearer sk-xxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model_name": "kling-v3",
"prompt": "A cinematic shot of a red tram crossing a rainy city street at night, reflections on the road",
"negative_prompt": "blur, low quality",
"mode": "pro",
"sound": "off",
"aspect_ratio": "16:9",
"duration": "5",
"watermark_info": {"enabled": false}
}'Multi-shot Example
bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video" \
-H "Authorization: Bearer sk-xxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model_name": "kling-v3",
"multi_shot": true,
"shot_type": "customize",
"multi_prompt": [
{"index": 1, "prompt": "A quiet cafe at sunrise, warm light through the window", "duration": "2"},
{"index": 2, "prompt": "A close-up of coffee steam rising from a white cup", "duration": "3"}
],
"mode": "pro",
"sound": "on",
"aspect_ratio": "16:9",
"duration": "5"
}'Query Task
Request
http
GET /v1/videos/text2video/{task_id}Use data.task_id for polling.
Response
json
{
"code": 0,
"message": "success",
"request_id": "req_abc123",
"data": {
"task_id": "sg_vid_xxxxxxxx",
"task_status": "succeed",
"watermark_info": {
"enabled": false
},
"task_result": {
"videos": [
{
"url": "https://example.com/output.mp4"
}
]
},
"created_at": 1776209922,
"updated_at": 1776210072
}
}Status Values
task_status | Meaning |
|---|---|
submitted | Task accepted but not yet running. |
processing | Task is queued or running. |
succeed | Task completed and task_result.videos may be present. |
failed | Task failed or was cancelled. Check task_status_msg when present. |
Example
bash
curl -sS "https://api.exchangetoken.ai/v1/videos/text2video/sg_vid_xxxxxxxx" \
-H "Authorization: Bearer sk-xxxxxx"