Skip to main content
Try it · OpenAPI specification Use model kling-4.0 with the shared create-task endpoint. Authenticate using a GENGEN API key. Preview requests in API Explorer.

Workflows

All examples below use placeholder media URLs. Replace them with accessible HTTPS URLs before use. Images alone use the no video input billing tier.

Text to video

First frame

First and last frames

Multiple keyframes

Omni references

Video editing

Parameters and references

  • mode is optional: reference images/videos, a source video, elements or voices select omni_video; keyframes select image_to_video; otherwise the mode is text_to_video.
  • Output resolution is 720p or 1080p (default).
  • controls.duration is an integer from 3 to 30. An explicit value takes precedence over the prompt. If omitted, the model follows the duration requested in the prompt; without a duration instruction, Omni uses the source video’s duration when present, otherwise generation defaults to 10 seconds. The estimate/reservation still uses a maximum of 30 output seconds and final billing uses measured duration.
  • Text-to-video accepts 21:9, 16:9 (default), 9:16 or 1:1. Omni also accepts adaptive (default). Omit controls.ratio for image-to-video; images determine it.
  • In Omni, an explicit ratio takes precedence. With adaptive, the model follows the prompt’s ratio instruction, then the source video, keyframe images, other input videos, and finally 16:9. Among keyframes, the first frame takes precedence; without it, the first supplied keyframe is used.
  • controls.watermark defaults to false; set it to true to return the watermarked video in outputs.videos. Describe audio requirements in prompt.
  • Prompts must be nonblank. The mixed-language budget is ASCII code points / 26,000 + other Unicode code points / 11,000 ≤ 1.
  • Media accepts an HTTPS URL string or { "url": "https://…", "id": "image1" }. Reference the ID as @image1 in the prompt. IDs contain letters, numbers, underscores or hyphens, are 1–128 characters, and must be unique across the task. Without an explicit ID, defaults are firstFrame1, middleFrame1, lastFrame1, image1, video1 and sourceVideo1 (array entries increment the suffix).
  • Text-to-video uses the prompt alone. Image-to-video requires at least one keyframe. Omni can combine keyframes, reference images/videos and one source video.
  • Use the documented request fields; omit providerOptions or pass an empty object.
Describe what each reference should contribute: for example, preserve the appearance of @image1 while using only the movement from @video1. For editing, specify both what to change and what to preserve. Prompts can include positive and negative descriptions, event sequences, dialogue, ambient sound, music and sound effects.

Media limits

Provide accessible HTTPS media URLs without embedded credentials. Generated videos use 24 fps.

Elements and voices

Use up to seven official preset elements in assets.elements, for example { "elementId": "official-preset-id", "id": "character1" }. Up to three may be video elements. Their duration and count contribute to the video limits. Use up to three voices from the Kling voice directory in assets.voices. Each entry accepts a string voiceId and a unique reference id for use in the prompt. Elements and voices count toward the 15-reference total.

Billing duration

Let O be measured output seconds and I be total input video seconds, including reference videos, the source video and video character elements. The video-input formula is equivalently O + max(I, O). Final charges use measured durations and the customer rate fixed at submission. Input duration cannot be omitted from an estimate when videos are present. See pricing for customer rates.

Task lifecycle

Save the complete public kling40:… task ID and retrieve the task with the owning GENGEN API key. States are pending, processing, succeeded and failed. Successful results expose the video in outputs.videos after storage and settlement. Download links expire; copy the video to your storage or retrieve the task again for a fresh link. Repeated queries do not repeat the generation charge. After a timeout or uncertain response, query the existing task rather than submitting a replacement. If you have no task ID, contact support before retrying.