Nodes/KIE.ai Nodes Next/Kling 4.0 Reference To Video
ComfyUI Node

Kling 4.0 Reference To Video

The prompt is a casting call

By felipederosilva·Created 2 months ago·Updated 3 days ago· 3
Kling 4.0 Reference To Video
  • image_urls
  • video_1
  • video_2
  • video_3
  • video_4
  • video_5
  • video
  • url
  • all_urls_json
  • task_id
  • raw_json
  • credits_consumed
  • credits_left
◄prompt@Hero sits at the desk in @video_1, picks up the doll from @image_1, and greets using @Narrator►
◄duration5►
◄resolution720p►
◄keep_original_soundfalse►
◄elements[]►
◄voices[]►
◄aspect_ratioauto►
◄timeout_seconds1200►
◄callback_url►

This is the node you use when the prompt alone won't hold an identity: up to ten reference images, up to five reference clips, named subjects ("elements") and named voices, all addressed with @ tags in the prompt. It's overkill for "a cat on a skateboard" and exactly right for "the character from @image_1, doing that dance from @video_1, in @Hero's voice".

What it is

KIE_Next_kling_4_0_reference_to_video_a2508b77 is the reference-to-video sibling of Kling 4.0's keyframe node, generated by the KIE Next pack from KIE's own documentation. Closed model, remote render, native VIDEO out.

Here's the thing worth knowing before you start: KIE documents four material types, and all of them are optional. Supply nothing and this node quietly behaves as plain text-to-video. So it's not "reference to video plus a text mode" - it's one endpoint where your attachments determine the request.

How it works

Request, upload, create task, poll, download - the pack's standard path, with timeout_seconds defaulting to 1200. What's specific here is the addressing scheme, which KIE spells out in a table on the docs page:

| Material | Mention syntax | Limit | |---|---|---| | Reference images | @image_1, @image_2, … | 10 images | | Reference videos | @video_1, @video_2, … | 5 clips, 2–30s each, 30s combined | | Elements | @name | 7 items, at most 3 video subjects | | Voices | @name | 3 standalone voice references |

Your prompt must only mention assets you actually included, and the image/video indexes follow array order - 1-based. Same hard rule as the keyframe node: a mention with no matching asset gets the request rejected.

Also worth knowing: images, videos, elements and voices together cannot exceed 15 items. And the caps compound - five reference videos plus video subjects inside elements still has to stay at five, with 30 seconds of reference footage total.

The inputs that matter

prompt is required (up to 10,000 characters) and is where the @ references live. image_urls is a native IMAGE socket that takes a batch, up to ten refs, each side 300–65536px and aspect ratio 0.40–2.5. The reference videos are five separate VIDEO sockets - video_1 through video_5 - each 2–30 seconds.

elements and voices are raw JSON strings, not sockets, which is the one genuinely fiddly part of this node. You're typing configuration, default []. Element names are what you then reference as @name in the prompt, so keep them short and unambiguous. Same for voices: up to three, addressed by their name.

keep_original_sound only does anything when you supplied a reference video - it keeps that clip's audio. With no reference video, the tooltip says native audio is always generated, so there's nothing to preserve.

duration is 3–30 seconds (default 5), resolution is 720p or 1080p, and aspect_ratio (auto, 16:9, 9:16, 1:1, 21:9) resolves to auto when you supplied references and 16:9 when you didn't.

Outputs

video into KIE • Preview Video or KIE • Save Video (both under KIE Next / Utility / Media, both pass the VIDEO through). task_id for KIE • Reuse Completed Image/Video/Audio - which is genuinely handy here, because video runs are expensive enough that re-downloading beats re-rendering. url, all_urls_json, raw_json, credits_consumed, credits_left as usual. Nothing executes until the video is consumed downstream.

Installing it

Manager → "KIE.ai Nodes Next", or:

comfy node install kie-ai-nodes-next

Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/felipederosilva/ComfyUI-KIE-Nodes-Next
pip install -r requirements.txt

Restart ComfyUI, then Settings → KIE.ai Nodes Next → Connection to paste the key. It's checked against KIE before it replaces a saved one, and only a masked fingerprint is ever shown. Environment-variable keys aren't supported.

Dependencies: requests, Pillow, numpy, PyYAML. No model files, no VRAM requirements.

Where people get burned

The JSON fields. A malformed elements string is the most common way this node fails for beginners, and the pack's local preflight will catch structural problems before upload rather than after - use right-click → KIE Next · Check inputs & model controls to see what it expects.

Reference footage you didn't trim. Five clips at 30 seconds combined is a real cap, not a suggestion. Trim with ComfyUI's VideoTrim before wiring, or you'll be hunting a rejection that says nothing about duration.

Trusting it as an identity lock. A reference image plus a prompt is not a face guarantee on any model, and Kling is no exception; the same holds for voices. Expect "recognisably the same person, mostly" and plan a retry budget.

Audio you didn't mean to keep. Flip keep_original_sound on with a reference clip and you'll ship the source video's room tone into the render.

CategoryKIE Next/Video/Kling

Inputs (15)

NameTypeDefaultDescription
promptSTRING@Hero sits at the desk in @video_1, picks up the doll from @image_1, and greets using @NarratorVideo description. Required. Maximum 10000 characters. Use `@` to mention assets uploaded in this request: - `@image_1`, `@image_2`, … map to `image_urls` in order (1-based) - `@video_1`, `@video_2`, … map to `video_urls` - `@name` maps to the `name` of an item in `elements` or `voices` Every `@` mention must match an asset included in this request, otherwise the request is rejected. Mentions use longest-match against declared names. If the matched name ends with a letter, digit, or underscore, the next character cannot be a letter, digit, or underscore.
durationoptINT53–30Output video duration in seconds. Integer from 3 to 30. Default: `5`.
resolutionoptCOMBO720pOutput resolution. `720p` or `1080p`. Default: `720p`.
image_urlsoptIMAGEReference images, up to 10 publicly accessible URLs. Mention them in the prompt as `@image_1`, `@image_2`, … in array order. Each side must be 300–65536 pixels; aspect ratio 0.40–2.5.
video_1optVIDEOReference videos, up to 5 clips, each 2–30 seconds. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total, and their combined duration cannot exceed 30 seconds.
video_2optVIDEOReference videos, up to 5 clips, each 2–30 seconds. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total, and their combined duration cannot exceed 30 seconds.
video_3optVIDEOReference videos, up to 5 clips, each 2–30 seconds. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total, and their combined duration cannot exceed 30 seconds.
video_4optVIDEOReference videos, up to 5 clips, each 2–30 seconds. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total, and their combined duration cannot exceed 30 seconds.
video_5optVIDEOReference videos, up to 5 clips, each 2–30 seconds. Mention them in the prompt as `@video_1`, `@video_2`, …. Reference videos plus video subjects in `elements` cannot exceed 5 in total, and their combined duration cannot exceed 30 seconds.
keep_original_soundoptBOOLEANfalseWhether to keep the original audio of the reference videos. Only takes effect when `video_urls` is provided. Default: `false`. If no reference video is provided, native audio is always generated.
elementsoptSTRING[]Subjects used only for this task. Up to 7 items, of which at most 3 can be video subjects. Mention them in the prompt as `@name`. `image_urls`, `video_urls`, `elements`, and `voices` together cannot exceed 15 items.
voicesoptSTRING[]Standalone voice references used only for this task. Up to 3 items. Mention them in the prompt as `@name`. Audio bound on a subject via `voice_url` is separate and does not count toward this quota.
aspect_ratiooptCOMBOautoOutput aspect ratio. Optional. - If omitted and any reference asset is provided, the model uses `auto` - If omitted and no reference asset is provided, the model uses `16:9`
timeout_secondsoptINT120030–7200—
callback_urloptSTRINGOptional KIE callback URL. Leave empty for normal ComfyUI use.

Outputs (7)

NameTypeDescription
videoVIDEO—
urlSTRING—
all_urls_jsonSTRING—
task_idSTRING—
raw_jsonSTRING—
credits_consumedFLOAT—
credits_leftFLOAT—