Nodes/ComfyUI API Toolkit/Kling Create Element
ComfyUI Node

Kling Create Element

Build the Character Once, Reuse It Everywhere

By IxMxAMAR·Created 7 months ago·Updated 23 days ago· 1
Kling Create Element
  • auth
  • frontal_image
  • refer_image_1
  • refer_image_2
  • refer_image_3
  • element_id
  • task_id
◄element_name►
◄element_description►

Keeping the same character across generations is the oldest unsolved problem in this ecosystem. The local answers are LoRA training (works, costs you a dataset and an afternoon), IP-Adapter and friends (zero-shot, fiddly, and the stack has largely been overtaken by instruction editing), or the turnaround-sheet trick. Kling's element library is a fourth answer, and it's the cloud one: register a character once, get an id back, hand that id to every subsequent generation.

This node is the registration step. It's not the interesting one visually - it makes no pixels - but everything else in the Kling half of your workflow depends on it.

The inputs

auth comes from the pack's Kling AI Authentication node. Wire it in; you never type keys into this node directly.

element_name caps at 20 characters, element_description at 100. Those aren't soft limits - they're what the API accepts, and the tooltip is the author telling you so before you find out the hard way.

Then the images. frontal_image is the good shot: face-on, well lit, subject filling the frame. refer_image_1 is required too, and the tooltip explains what it should be - another angle or a close-up. refer_image_2 and refer_image_3 are optional and get folded into the same request if you supply them. The pictures are a character reference sheet, in other words: you're giving the service the same information a LoRA training run would have extracted.

Both outputs are strings. element_id is the one you'll actually use - feed it to Video Omni or Image Omni, which take element_ids, and the character should come back recognisable. task_id is the Kling-side job id, useful if you want to trace a run in their dashboard.

How it works

The node POSTs to /v1/general/advanced-custom-elements with reference_type: "image_refer" and the frontal image plus your reference list, all base64-encoded. Elements are their own asynchronous job type, so the node polls that endpoint until the task succeeds and then reads task_result.elements[0].element_id. If the task reports success but the elements array is empty, the node raises an exception that dumps the response keys - a deliberate bit of debugging help, and a sign the author hit that case himself.

Note there's no image-cropping step anywhere in this path. Whatever you feed in is what the service sees.

Installing

Kling is the lightest of the three services in this pack:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-API-Toolkit
cd ComfyUI-API-Toolkit
pip install -r requirements.txt

For Kling alone that's requests and PyJWT - no model weights, nothing on your GPU. Manager users can search "API Toolkit" instead. Keys go in the Kling AI Authentication node, and KLING_API_KEY (or KLING_ACCESS_KEY plus KLING_SECRET_KEY) work as environment fallbacks. If the Kling nodes are missing from your menu entirely, PyJWT didn't install; the pack loads each service independently, so a missing dependency takes down one service rather than the app.

The things that will annoy you

Elements live in your Kling account, not in your workflow JSON. This is the big one. A shared workflow carries the element_id string, but the element itself is server-side and tied to your account. Send a friend a workflow and their graph will reference an element they don't own. Same if you switch API keys.

It costs credits every call. All Kling generation is metered per job, and there's no local fallback for any of it. Get the reference images right before you register four versions of the same character.

Bad frontal images produce bad elements - and you won't find out until you've generated video with it. Check the frontal image is actually frontal, and crop to the subject first. Kling does not crop for you.

Pair it with Subject Angles. Rather than hunting down reference images by hand, run the frontal image through the pack's Kling Subject Angles node and use the angles it returns as refer_image_1 through _3. That's the same turnaround-sheet logic people use locally, except the service draws the other side of the head for you.

CategoryAPI Toolkit/Kling AI/Config

Inputs (7)

NameTypeDefaultDescription
authKLING_AUTH—
element_nameSTRINGElement name (max 20 characters).
element_descriptionSTRINGElement description (max 100 characters).
frontal_imageIMAGEFrontal reference image of the element.
refer_image_1IMAGEReference image from another angle or a close-up.
refer_image_2optIMAGE—
refer_image_3optIMAGE—

Outputs (2)

NameTypeDescription
element_idSTRING—
task_idSTRING—