The Kling video generation model supports text-to-video, image-to-video from a first frame, image-to-video from first and last frames, reference-to-video, and video editing .
Activate the service
Go to the Alibaba Cloud Model Studio console, search for "kling", locate the Kling AI model card, click Activate Now, and then confirm activation and authorization in the pop-up window.
Model overview
Model name | Capabilities | Input modalities | Output video specs |
|---|---|---|---|
kling/kling-v3-turbo-video-generation |
| Text, image | Resolution mode: std (720P), pro (1080P) Aspect ratio: 16:9, 9:16, 1:1 Video duration: 3-15s Video format: MP4 |
kling/kling-v3-video-generation |
| Text, image | Resolution mode: std (720P), pro (1080P), 4k Aspect ratio: 16:9, 9:16, 1:1 Video duration: 3-15s Video format: MP4 |
kling/kling-v3-omni-video-generation |
| Text, image, video | Resolution mode: std (720P), pro (1080P), 4k Aspect ratio: 16:9, 9:16, 1:1 Video duration: 3-15s Video format: MP4 |
Scope
To ensure successful calls, make sure that the model, Endpoint URL, and API Key all belong to the same region. Cross-region calls will fail.
- Select a model: Confirm the region to which the model belongs.
- Select a URL: Select the corresponding regional Endpoint URL. HTTP URLs are supported.
- Configure an API Key: Select a region and obtain an API key. Then, configure the API key as an environment variable (to be deprecated and merged into API key configuration).
HTTP invocation
Video generation tasks take a long time—typically 1 to 5 minutes—so the API uses asynchronous invocation. The process involves two main steps: Create a task → Poll for the result. The steps are as follows:
Step 1: Create a task and get the task ID
Beijing region: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Replace {WorkspaceId} with your actual workspace ID.
- After the task is created, use the returned
task_idto query the result. Thetask_idis valid for 24 hours. Do not create duplicate tasks. Instead, use polling to retrieve the result. - For guidance for beginners, see Call APIs with Postman or cURL.
Request parametersHeadersContent-Typestring (Required)The content type of the request. Must be application/json.Authorization string (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.X-DashScope-Async string (Required)Enables asynchronous processing. HTTP requests support only asynchronous calls. Must be enable.Request Bodymodelstring (Required)The model name.Valid values:
object (Required)Basic input information, such as prompts and media assets.
Properties prompt string (Conditionally required)The text prompt describes the desired elements and visual features in the generated video.Chinese and English are supported. Each Chinese character or letter counts as one character. The maximum length is 2,500 characters. Exceeding the limit will result in an error.Logic:
string (Optional)The negative prompt describes what you do not want to appear in the result. Maximum 2,500 characters.
array (Optional)You do not need to specify this parameter for text-to-video tasks.A list of media assets used to specify image or video materials.Different models support different combinations of media assets:
Asset combination rules
kling/kling-v3-turbo-video-generation Only the following media asset combinations are supported. Invalid combinations will cause an error.
kling/kling-v3-video-generation Only the following media asset combinations are supported. Invalid combinations will cause an error.
kling/kling-v3-omni-video-generation Only the following media asset combinations are supported. Invalid combinations will cause an error.
Properties type string (Required)The type of media asset. The valid values depend on the selected model:
kling/kling-v3-turbo-video-generation Valid values:
last_frame is not supported. For restrictions on combinations of different media assets, see "Asset combination rules" under the media parameter.
kling/kling-v3-video-generation Valid values:
media parameter.
kling/kling-v3-omni-video-generation Valid values:
media parameter.string (Required)The URL of the media asset. Assets include images and videos.
Pass an image (type=first_frame, last_frame, or refer) The image URL.
Pass a video (type=base or feature) The URL of the video file.
string (Optional)Supported model: kling/kling-v3-omni-video-generation.Effective condition: This parameter takes effect only when a video is passed (type=base or feature).Specifies whether to keep the original video's sound.
boolean (Optional)Specifies whether to enable multi-shot generation.
string (Conditionally required)Required when multi_shot=true. The type of multi-shot mode.
array (Conditionally required)Required when shot_type=customize. A list of segments for the custom multi-shot mode.
Properties index integer (Required)The index of the shot segment. The number of shots can be from 1 to 6. The index starts from 1.prompt string (Required)The prompt for the corresponding segment. Chinese and English are supported. The maximum length is 512 characters. Excess characters are automatically truncated.duration integer (Required)The duration of the corresponding segment, in seconds.The value must be an integer between 1 and parameters.duration.array (Optional)A list of entities to be included in the video.Note: kling/kling-v3-turbo-video-generation does not support entities. Do not pass this field.
Properties element_id integer (Conditionally required)Required when passing element_list. It represents the entity ID. Retrieve the entity ID from the Kling - Entity ID List.Entity count limit (element_list array length limit):
object (Optional)Video generation parameters. You can set the generation mode, aspect ratio, video duration, and whether to generate audio.
Properties mode string (Optional)The video generation mode.
kling/kling-v3-turbo-video-generation only supports std (720P) and pro (1080P). 4K is not supported.aspect_ratio string (Conditionally required)The aspect ratio of the generated video.Valid values:
You do not need to set this in other scenarios
integer (Optional)The duration of the generated video, in seconds.
boolean (Optional)Specifies whether to generate a video with sound. If enabled, the model automatically generates matching background music or sound effects based on the video content.
boolean (Optional)Specifies whether to simultaneously generate a watermarked version of the video. The watermark is located in the lower-right corner and displays "Kling AI". When set to true, the response will additionally return the watermark_video_url field.
|
Supported models: kling/kling-v3-turbo-video-generation, kling/kling-v3-video-generation, and kling/kling-v3-omni-video-generation. |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringUnique request identifier for tracing and troubleshooting.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes. |
Save the task_id to query the task status and result. |
Step 2: Query the result by task ID
Beijing region: GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/tasks/{task_id}
- Polling recommendation: Video generation takes several minutes. Use a polling mechanism with a reasonable query interval (such as 15 seconds) to retrieve the result.
- Task status flow: PENDING (In queue) → RUNNING (Processing) → SUCCEEDED (Successful) / FAILED (Failed).
- task_id validity: 24 hours. After this period, you cannot query the result, and the API returns the task status as
UNKNOWN. - RPS limit: The default records per second (RPS) for the query API is 20. For higher-frequency queries or event notifications, configure an asynchronous task callback.
- More operations: To perform operations such as batch queries or canceling tasks, see Manage asynchronous tasks.
Request parametersHeadersAuthorizationstring (Required)Authenticates the request with a Model Studio API key. Example: Bearer sk-xxxx.URL path parameterstask_idstring (Required)The ID of the task. |
Replace {task_id} with the task_id value returned by the previous API call. The task_id is valid for queries for 24 hours, Replace {WorkspaceId} with your actual workspace ID. |
Response parametersoutputobjectTask output information.
Properties task_id stringThe task ID. Valid for queries for 24 hours.task_status stringThe status of the task.
Enumeration values
stringThe time when the task was submitted. format is YYYY-MM-DD HH:mm:ss.SSS.scheduled_time stringThe time when the task was executed. format is YYYY-MM-DD HH:mm:ss.SSS.end_time stringThe time when the task was completed. format is YYYY-MM-DD HH:mm:ss.SSS.video_url stringThe video URL. This is returned only when task_status is SUCCEEDED.The video is in MP4 format (H.264 encoding). The video link is valid for 30 days, but do not rely on it for long-term storage. Download the video promptly.watermark_video_url stringThe URL of the video with a watermark. This is returned only when task_status is SUCCEEDED.The video is in MP4 format (H.264 encoding). The video link is valid for 30 days, but do not rely on it for long-term storage. Download the video promptly.orig_prompt stringThe original input prompt, corresponding to the request parameter prompt.code stringError code. Returned only for failed requests. See Error codes.message stringDetailed error message. Returned only for failed requests. See Error codes.objectStatistics for the output information. Only successful results are counted.
Properties duration integerThe total duration of the generated video, used for billing.size stringThe resolution of the generated video. Example: 1280×720.fps integerThe frame rate of the generated video. Example: 24.SR stringThe resolution tier of the generated video. Example: 720.audio booleanIndicates whether the generated video has sound. Example: false.video_count integerThe number of generated videos. This is fixed at 1.stringUnique request identifier for tracing and troubleshooting. |
|