AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help
Video generationKling

Omni video generation

Generate or edit Kling 4.0 video using multiple types of reference assets.

feature_video references a video's features and motion rhythm; base_video edits an existing video. Images, videos, elements, and voices may total up to 15 items and must also meet each asset type's limits. Elements and voices use existing IDs; asset management APIs are not included on this page.

POST/kling/omni-video/kling-4.0

Combine prompts, images, videos, elements, and voices to generate or edit video. feature_video provides a video reference; base_video enables editing. Omni uses the same Kling 4.0 model as the other two generation endpoints.

Authorization

bearerAuth
AuthorizationBearer <token>

Use a platform API Key: Authorization: Bearer your-api-key.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

Asset types and references

contents must contain a prompt item type: "prompt". Add other assets as needed. id is used for @reference in prompts; all supplied asset reference IDs must be unique within the task.

AssettypeSource and required fields
Imagefirst_frame / middle_frame / last_frame / refer_imageurl required; URL or Base64; id optional
Videofeature_video / base_videourl required; video URL; id optional
ElementelementBoth element_id and id required
VoicevoiceBoth voice_id and id required

element_id is a system-generated element ID obtained from element APIs. voice_id is a voice ID; use custom voice APIs for custom voices or the system preset voices documented by the provider. These are different from the asset reference id within this request.

See the official element library guide for element concepts and usage, and the official voice customization documentation for voice sources. Use asset IDs for the appropriate region; do not reuse preset IDs from another region.

Asset limits

AssetFormat and sizeDimensions, duration, and count
ImageJPG, JPEG, PNG; up to 30MB eachWidth and height at least 300px; ratio 2:5–5:2; up to 10 images
VideoMP4, MOV; up to 300MB eachEach video and total input duration: 3–30 seconds; dimensions 700–4553px, at most 8294400 pixels; ratio 2:5–5:2; input 24–60fps, output 24fps
ElementMulti-image or video character elementsUp to 7 elements, including up to 3 video character elements
VoiceExisting custom or system preset voicesUp to 3

Asset combinations must also satisfy these limits:

  • Images, videos, elements, and voices total no more than 15 items.
  • Videos and video character elements total no more than 5; at most 1 base_video video.
  • Total input video duration includes feature_video, base_video, and the source videos of video character elements.

Common errors and troubleshooting

Response or errorWhat to check
HTTP 401, Invalid tokenCheck Bearer authentication and whether the API Key belongs to the requested site
HTTP 400, contents cannot be emptyProvide a nonempty contents array
HTTP 400, prompt cannot be emptyAdd a nonempty text item of type: "prompt" to contents
HTTP 400, contents[0].type ... is invalidUse the documented asset types and check the item at the reported index
HTTP 400, Invalid element idCheck element_id; do not substitute this request's reference id for the element ID
HTTP 400, Invalid voice idCheck voice_id; do not substitute this request's reference id for the voice ID
HTTP 400, invalid JSON request bodyCheck JSON quotes, commas, brackets, and comments

HTTP 400 may return code/message/data or an error object. Find the cause of fail_to_fetch_task in message, which may be a JSON string containing code/message/request_id. Keep the request ID for troubleshooting, but do not share your API Key.