Skip to content

Kling โ€‹

Updated

Endpoint: POST https://mps.intl.tencentcloudapi.comAction: CreateAigcVideoTask

Kling is one of the most full-featured video generation models, supporting text-to-video, first-frame / first-and-last-frame video generation, and multimodal reference generation from images and video. 3.0-Omni / O1 support multi-shot generation (smart storyboarding) and video editing, with extended capabilities such as motion control, lip sync, digital humans, and custom voices, and can generate audio at the same time.

Basic Information โ€‹

ItemValue
ModelNameKling
ModelVersion4.0-Omni / 4.0 / 3.0-Omni / 3.0 / O1 / 2.6 / 2.5 / 2.1 / 2.0 / 1.6
Guardrail disable supportSupported

It is the video engine with the widest range of features in MPS AIGC. In addition to text-to-video, image-to-video (first/last frame), and reference generation, it handles motion control, lip sync, digital human, multi-shot, custom reference subject, and custom voice through SceneType and AdditionalParameters.

Request Parameters โ€‹

ParameterRequiredTypeDescription
ModelNameRequiredStringFixed value Kling
ModelVersionOptionalString4.0-Omni / 4.0 / 3.0-Omni / 3.0 / O1 / 2.6 / 2.5 / 2.1 / 2.0 / 1.6
PromptRequiredStringGeneration prompt. In text input mode, write up to a maximum of 2000 characters
NegativePromptOptionalStringElements to exclude from the result. Applied on supported models
EnhancePromptOptionalBooleanAutomatic prompt correction. Default value false
ImageUrlOptionalStringFirst frame image URL. Must be externally accessible and 10MB or less
LastImageUrlOptionalStringLast frame image URL. Used together with ImageUrl
ImageInfos.NOptionalArrayReference image array. Category / Url / ReferenceType, etc.
DurationOptionalIntegerGeneration length (seconds). Only allowed values per model are applied
ExtraParametersOptionalObjectResolution / AspectRatio / EnableAudio
AdditionalParametersOptionalStringJSON string containing model-specific options. For the seed delivery format, see Additional configuration reference
SceneTypeOptionalStringmotion_control (motion control), lip_sync (lip sync), avatar_i2v (digital human), multi_elements (multi-element editing)
ExtraParameters.
EnablelnputComplianceCheck
OptionalBooleanIf false is explicitly passed, input moderation is disabled. Contact your sales representative before use
ExtraParameters.
EnableOutputComplianceCheck
OptionalBooleanIf false is explicitly passed, output moderation is disabled. Contact your sales representative before use

Request Example โ€‹

text-to-video โ€‹

For text generation, enter Prompt, and use ExtraParameters to specify resolution / aspect ratio / simultaneous audio generation.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "Prompt": "a cat walking on the beach at sunset",
  "Duration": 5,
  "ExtraParameters": {
    "Resolution": "1080P",
    "AspectRatio": "16:9",
    "EnableAudio": true
  },
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Response Example โ€‹

json
{
  "Response": {
    "Status": "DONE",
    "Message": "ok",
    "Resolution": "1920x1080",
    "VideoUrls": [
      "https://aigc-output-video-<id>.cos.<region>.myqcloud.com/<file>.mp4?q-sign-algorithm=sha1&..."
    ],
    "RequestId": "<request-id>"
  }
}

Special Configuration โ€‹

Guardrail Disable โ€‹

Input and output moderation can be configured separately.

To use the guardrail disable parameters, you must first contact your sales representative to confirm usage permission. Even on supported engines, the guardrail is disabled only when the parameter is explicitly passed. If the parameter is omitted, it is not disabled.

ParameterDisable ValueTarget
ExtraParameters.EnablelnputComplianceCheckfalseInput moderation disabled
ExtraParameters.EnableOutputComplianceCheckfalseOutput moderation disabled

Merge the following configuration into an existing generation request. To disable both input and output moderation, pass both fields together.

json
{
  "ExtraParameters": {
    "EnablelnputComplianceCheck": false,
    "EnableOutputComplianceCheck": false
  }
}

Supported Capabilities by Version โ€‹

VersionGeneration ModeMaximum Reference ImagesAudioLength
3.0-Omnitext / image / reference generation8 imagesOriginal sound, dubbing, sound effects3~15 seconds
3.0text / image6 imagesSupported3~15 seconds
O1text / image / reference generation4 imagesSupported3~10 seconds
2.6text / image4 imagesSupported in reference generation + pro mode (1080P)5 seconds, 10 seconds
2.1 / 2.0 / 1.6text, default imageโ€”Simple background sound only5 seconds, 10 seconds

Kling 4.0 (new generation) โ€‹

Kling 4.0 / 4.0-Omni is the latest generation. Compared with the 3.0 series, it raises the maximum reference images to 10 and extends the per-task duration to 3~30 seconds. The calling convention is identical to general Kling โ€” just set ModelVersion to 4.0 or 4.0-Omni; all other parameters (Prompt / ImageUrl / ImageInfos.N / Duration / ExtraParameters, etc.) follow the common definitions above on this page.

VersionGeneration ModeMaximum Reference ImagesLength
4.0-Omnivideo-reference-to-video10 images3~30 seconds
4.0text / image (text-to-video / image-to-video)10 images3~30 seconds
  • 4.0: general generation for text-to-video and image-to-video (first frame / first-and-last frame).
  • 4.0-Omni: targets video-reference-to-video (generation driven by a reference video); reference material is passed through ImageInfos.N / reference-video-info fields.

Request Example (text-to-video, 4.0) โ€‹

In the JSON below, Prompt, Duration, resolution, CosBucketName, etc. are example / reference values. Use your own business parameters and real data in practice.

json
{
  "ModelName": "Kling",
  "ModelVersion": "4.0",
  "Prompt": "a cat walking on the beach at sunset",
  "Duration": 10,
  "ExtraParameters": {
    "Resolution": "1080P",
    "AspectRatio": "16:9"
  },
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Request Example (video-reference-to-video, 4.0-Omni) โ€‹

The reference video URL, Duration, etc. are example / reference values. Use real material and business parameters in practice.

bash
curl -X POST https://mps.tencentcloudapi.com \
  -H "Content-Type: application/json" \
  -H "X-TC-Action: CreateAigcVideoTask" \
  -H "X-TC-Version: 2019-06-12" \
  -H "X-TC-Region: ap-guangzhou" \
  -H "Authorization: TC3-HMAC-SHA256 Credential=<SecretId>/<Date>/mps/tc3_request, SignedHeaders=content-type;host, Signature=<Signature>" \
  -d '{
  "ModelName": "Kling",
  "ModelVersion": "4.0-Omni",
  "Prompt": "recreate the scene following the reference video",
  "ImageInfos": [
    { "Category": "Video", "Url": "https://<cdn>/reference.mp4" }
  ],
  "Duration": 10,
  "Operator": "admin"
}'

image-to-video (first / last frame) โ€‹

Specifying the first frame with ImageUrl makes it image-to-video. Adding LastImageUrl together stitches the two frames together. If only the first frame is provided, the output aspect ratio follows that image's aspect ratio. The last frame is supported in 2.0 / O1 / 3.0 / 3.0-Omni.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "Prompt": "smooth transition between two scenes",
  "ImageUrl": "https://<cdn>/first.png",
  "LastImageUrl": "https://<cdn>/last.png",
  "Duration": 10,
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Reference Generation (Multi-Image) โ€‹

Put multiple reference images in ImageInfos.N, and point to each image in Prompt in the form <<<image_1>>> / <<<image_2>>>. O1 and 3.0-Omni accept up to 1~7 images, and 1.6 accepts up to 1~4 images.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0-Omni",
  "Prompt": "<<<image_1>>> and <<<image_2>>> in the same scene",
  "ImageInfos": [
    {
      "Category": "Image",
      "Url": "https://<cdn>/ref1.png"
    },
    {
      "Category": "Image",
      "Url": "https://<cdn>/ref2.png"
    }
  ],
  "Duration": 10,
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Motion Control (motion_control) โ€‹

Generates so that the person in the reference image follows the specified pose and motion. Specify SceneType=motion_control, and specify the motion control detail options in AdditionalParameters as a JSON string. Supports keep_original_sound / character_orientation, etc. Use ModelVersion=3.0 for the latest motion control and 2.6 for the standard path.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0-Omni",
  "SceneType": "motion_control",
  "Prompt": "a person waves hand and turns around",
  "ImageUrl": "https://<cdn>/first-frame.png",
  "Duration": 5,
  "ExtraParameters": {
    "Resolution": "1080P",
    "AspectRatio": "16:9"
  },
  "AdditionalParameters": "{\"keep_original_sound\":\"yes\"}",
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Lip Sync (lip_sync) โ€‹

It proceeds in two steps. First, retrieve session_id and face_id through the face information query API, then put those values into AdditionalParameters to create a generation task. For short and simple videos use the synchronous API DescribeAigcFaceInfo; for long and complex videos use the asynchronous API DescribeAigcFaceInfoAsync. The version does not matter and any value works.

bash
curl -X POST https://mps.tencentcloudapi.com \
  -H "X-TC-Action: DescribeAigcFaceInfo" \
  -H "Content-Type: application/json" \
  -H "X-TC-Version: 2019-06-12" \
  -H "X-TC-Region: ap-guangzhou" \
  -H "Authorization: TC3-HMAC-SHA256 Credential=<SecretId>/<Date>/mps/tc3_request, SignedHeaders=content-type;host, Signature=<Signature>" \
  -d '{
  "ImageUrl": "https://<cdn>/portrait.png",
  "ModelName": "Kling",
  "ModelVersion": "3.0"
}'
bash
curl -X POST https://mps.tencentcloudapi.com \
  -H "X-TC-Action: CreateAigcVideoTask" \
  -H "Content-Type: application/json" \
  -H "X-TC-Version: 2019-06-12" \
  -H "X-TC-Region: ap-guangzhou" \
  -H "Authorization: TC3-HMAC-SHA256 Credential=<SecretId>/<Date>/mps/tc3_request, SignedHeaders=content-type;host, Signature=<Signature>" \
  -d '{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "SceneType": "lip_sync",
  "ImageUrl": "https://<cdn>/portrait.png",
  "AdditionalParameters": "{\"session_id\":\"<session-id>\",\"face_choose\":\"<face-id>\"}",
  "Operator": "admin"
}'

Digital Human (avatar_i2v) โ€‹

Creates a talking video from a person image and an audio file. Specify SceneType=avatar_i2v, pass the image through Category=Image of ImageInfos.N, and the audio through sound_file of AdditionalParameters. Audio supports mp3, wav, m4a, and aac, must be 5MB or less, and within the 2~300 seconds range. The version does not matter.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "SceneType": "avatar_i2v",
  "Prompt": "a digital human talking",
  "ImageInfos": [
    {
      "Category": "Image",
      "Url": "https://<cdn>/avatar.png"
    }
  ],
  "AdditionalParameters": "{\"sound_file\":\"https://<cdn>/voice.mp3\"}",
  "Duration": 5,
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Multi-shot (Storyboard) โ€‹

Generates multiple shots in a single task in the 3.0 series. Specify multi_shot / shot_type / multi_prompt in AdditionalParameters.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "Prompt": "a short cinematic sequence in three shots",
  "Duration": 15,
  "AdditionalParameters": "{\"multi_shot\":\"true\"}",
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Custom Voice (voice_id) โ€‹

Create a voice with the custom voice creation API, and specify voice_id with voice_list in AdditionalParameters of the generation request. Supported in 2.6 / 3.0 / 3.0-Omni; for 2.6, the voice setting is applied only in 1080P.

json
{
  "ModelName": "Kling",
  "ModelVersion": "3.0",
  "Prompt": "a narrator introduces the product",
  "Duration": 10,
  "ExtraParameters": {
    "Resolution": "1080P",
    "EnableAudio": true
  },
  "AdditionalParameters": "{\"voice_list\":[{\"voice_id\":\"<voice-id>\"}]}",
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Multi-Element Editing (multi_elements) โ€‹

MPS CreateAigcVideoTask also supports SceneType=multi_elements. Pass session_id and edit_mode in AdditionalParameters.

Selection session is exclusive to VOD

The InitializeAigcMultiElementsSelection / EditAigcMultiElementsSelection session API that creates the selection area is exclusive to VOD. Therefore, first create the selection session through the VOD path, then use the issued session_id in the MPS generation request. For the overall 3-step flow and the parameters of the session API, refer to the multi-element editing section of the VOD Kling document.

json
{
  "ModelName": "Kling",
  "ModelVersion": "1.6",
  "SceneType": "multi_elements",
  "Prompt": "Regenerate a specific subject in <<<video_1>>>",
  "Duration": 10,
  "AdditionalParameters": "{\"session_id\":\"<session-id>\",\"edit_mode\":\"addition\"}",
  "Operator": "admin",
  "StoreCosParam": {
    "CosBucketName": "<bucket-appid>",
    "CosBucketRegion": "<bucket-region>",
    "CosBucketPath": "/aigc/"
  },
  "EnhancePrompt": false
}

Additional Options โ€‹

Custom Reference Subject

Kling custom reference subjects are created, queried, and deleted through a separate API. Use CreateKlingCustomElement / CreateAigcCustomElement / DescribeKlingCustomElement / DeleteAigcAdvancedCustomElement, and manage the domestic reference subject library and the overseas reference subject library separately.

Built with VitePress ยท Deployed on Tencent EdgeOne Pages