contents array of a kling/kling-4.0 request. This page covers how to send them. The full request schema is on the Kling 4.0 model page.
Element and voice items
Each item incontents has a type. Elements and voices use these fields:
id is a reference name you choose for the item. Kling requires it on every element and voice item, and it must be unique within the request. element_id and voice_id must be strings.
Reference elements and voices in the prompt
Put the prompt incontents as an item of type prompt, and refer to other inputs by writing @ followed by their id. With an element whose id is hero and a voice whose id is narrator, the prompt can say @hero and @narrator.
Do not send a top-level prompt field together with a non-empty contents array. Router refuses that combination; the prompt belongs inside contents.
How Router picks the mode
kling/kling-4.0 has one model ID and three modes. Router selects the mode from the request body:
- Text-to-video: a top-level
promptand nocontents(or an emptycontents). - Image-to-video:
contentsholding onlyprompt,first_frame,middle_frameandlast_frameitems. - Omni video:
contentsholding any other type, includingrefer_image,feature_video,base_video,elementorvoice.
element or voice item therefore sends the request to omni video. You do not set the mode yourself.
Limits
Omni video accepts up to 15 inputs plus the prompt, so Router refuses acontents array of more than 16 items. Within that, a request may hold at most:
- 10 images (
first_frame,middle_frame,last_frameandrefer_imagecombined) - 5 videos (
feature_videoandbase_videocombined), with at most onebase_video - 7 elements
- 3 voices
422 and a detail[] entry naming contents. See validation errors.
A request that includes a video character element bills at the video-input rate, as do requests with a feature_video or base_video.
Example request
This queues an omni video generation with one element and one voice. Replace the placeholder IDs with your own.201 with a request_id. Poll and collect the result as described in Queued delivery. To wait for the result in one call instead, send the same body to POST https://api.comfy.org/v2/models/kling/kling-4.0.
Getting element and voice IDs
Router does not offer endpoints to create, upload or list Kling elements or voices. It only passes theelement_id and voice_id values you send to Kling.
Kling ties element IDs and custom voice IDs to the Kling account that created them. Router sends requests to Kling with Comfy’s credentials, not with yours, so an element or custom voice created in your own Kling account may be rejected.
To keep a subject consistent without an element, send reference images as refer_image items or a reference video as a feature_video item, and give each one an id to reference in the prompt.