Skip to main content
POST
This endpoint is asynchronous. After submission, use the returned task_id with GET /v1/videos/generations/{task_id} to query the task status and result.

Mode selection

All five modes use the same model name, kling-v4. The mode is selected from the supplied assets and omni_reference_task_type. omni_reference_task_type defaults to auto, equivalent to omitting it. When explicitly set to reference, images in image_urls are treated as reference images.
Supplying only video_url without specifying edit or extend returns HTTP 400. To use a video as a reference asset, use video_urls.

Request headers

string
required
Bearer authentication: Bearer <token>, where <token> is your APIMart API Key.

Request parameters

string
required
Must be kling-v4.
string
Describe the content to generate or edit. Optional for image-to-video; required for all other modes.In reference-based generation, use @Image1, @Video1, and @Audio1 to refer to assets, numbered from 1 in each asset array. In video editing, the input video is @Video1, and reference images are @Image1, @Image2, and so on.
integer
Generated duration in seconds, from 3 to 30; default: 5.
  • Video editing: when omitted, the output duration follows the input video.
  • Video extension: the duration of the new segment. The returned video combines the original video and the new segment.
string
default:"720p"
Output resolution: 720p or 1080p. Use this field to select the resolution; V4 does not support mode.
string
Supports 16:9, 9:16, 1:1, and 21:9. Reference-based generation also supports auto.
string[]
Image URL list, interpreted according to the mode:
  • Image-to-video: the first image is the first frame and the second is the last frame; up to 2 images.
  • Reference-based generation and video editing: up to 10 reference images. For generation using only reference images, explicitly set omni_reference_task_type: "reference".
Asset URLs must be publicly accessible.
object[]
Image list with roles. Each item contains url and role.For image-to-video, the first frame, last frame, and intermediate frames must total no more than 10 images.
string
First-frame image URL for image-to-video. It can also be supplied as first_frame in image_with_roles, or as the first image in image_urls.
string
Last-frame image URL for image-to-video, or target last-frame image URL for extension.
string[]
Reference videos for reference-based generation: up to 5 clips, using no more than 30 seconds in total.For video editing or extension, you may instead supply exactly 1 video URL in place of video_url, with omni_reference_task_type: "edit" or "extend".
string
Input video URL for editing or extension. Requires omni_reference_task_type: "edit" or "extend".For editing, the input video must be at least 3 seconds; shorter videos return HTTP 400. Videos longer than 30 seconds are trimmed to the first 30 seconds.
string[]
Reference audio for reference-based generation: up to 3 clips, each 5–30 seconds long.Reference images, videos, and audio combined must total no more than 15 assets for reference-based generation.
string
default:"auto"
Supports auto, reference, edit, and extend.
  • auto: selects text-to-video, image-to-video, or reference-based generation from the assets; equivalent to omitting the field.
  • reference: reference-based generation; images in image_urls are treated as references.
  • edit: video editing; requires an input video.
  • extend: video extension; requires an input video.
string
Supports origin (preserve input video audio) and auto (generate new audio). Only for video editing or reference-based generation with reference videos.
  • Video editing: preserves the original audio by default; auto generates new audio.
  • Reference-based generation with reference videos: generates new audio by default; origin preserves reference video audio.
  • Video extension: this field is not supported. Original audio is preserved, and audio is generated automatically for the new segment.
V4 always outputs video with stereo audio, generating sound together with the visuals.

Request examples

Asset URLs below are placeholders. Replace them with real, publicly accessible URLs.

Image-to-video: first and last frames

The first image is the first frame, and the second is the last frame. prompt is optional for image-to-video.

Image-to-video: first, intermediate, and last frames

Intermediate frames are used in array order. Exactly 1 first frame is required, with no more than 10 images across the first, last, and intermediate frames.

Reference-based generation

Up to 10 reference images, 5 reference videos, and 3 reference audio clips, with no more than 15 assets combined. Reference videos use up to 30 seconds in total; each reference audio clip must be 5–30 seconds.

Video editing

The input video must be at least 3 seconds; videos longer than 30 seconds are trimmed to the first 30 seconds. If duration and aspect_ratio are omitted, the output follows the input video. Original audio is preserved by default; use audio_setting: "auto" to generate new audio.

Video extension

Extension starts from the final frame of the input video. The result combines the original video and the new segment; only the new segment duration is billed. Supply a target last frame with last_frame_image or last_frame in image_with_roles. Extension does not support aspect_ratio or audio_setting.

Query a task

Replace the task ID in the following request with the ID returned on submission:
Approximate generation time: 3 minutes for a 3-second 720p video, and 3.5 minutes for a 15-second video.

Billing

Billed per second. See Model Pricing for rates. 720p and 1080p are priced separately. Video editing and reference-based generation with reference videos use the video-input rate. Other modes use the standard generation rate. Input video seconds are calculated by summing clip durations, rounding up to a whole second, and capping at 30 seconds. For example, editing a 3.04-second video without duration produces 4 seconds, billed as 4 + 4 = 8 seconds. For editing and reference-based generation with reference videos, input video duration is probed at submission. A probe failure returns HTTP 400 without charging. Failed generations receive a full refund.

Unsupported parameters

The following parameters or values return HTTP 400:
  • mode: V4 has no std, pro, or 4k tiers. Use resolution.
  • negative_prompt, watermark: true, audio: false.
  • multi_shot, multi_prompt, element_list, video_list.
  • camera_control, voice_list.

Common errors