Nodes/ComfyUI API Toolkit/Kling AI Asset Upload
ComfyUI Node

Kling AI Asset Upload

Get your image or video onto Kling's servers as an asset

By IxMxAMAR·Created 5 months ago·Updated 2 months ago· 1
Kling AI Asset Upload
  • auth
  • image
  • asset_id
  • asset_url
asset_typeimage
image_path
video_path

Kling's API has an awkward two-step shape that most users trip over once: before you can do an image-to-video, lip-sync, or avatar job, the image or video has to live on Kling's servers as a registered asset - not just be a tensor in your graph. Some Kling nodes accept raw image tensors and upload internally. For the rest, and for the cases where you want to reuse one upload across several tasks, this node is the explicit upload step: it pushes your asset up, Kling returns an asset ID, and you feed that ID into the nodes that want it.

Think of it as the bridge between "my image exists in ComfyUI" and "Kling knows what I'm talking about." You'll reach for it when a downstream node's inputs expect an asset ID rather than an image, or when you're building a workflow that uses the same reference in multiple jobs and don't want to re-upload every time.

How it works

You pick an asset_type (image or video), supply the data in one of the accepted forms, and the node calls Kling's asset-upload endpoint. For images you can hand it a ComfyUI IMAGE tensor (it gets base64-encoded), or a path to an image file on disk via image_path. Videos are less flexible - the node requires a video_path on disk, so you'll want the pack's Raw File Loader or Video Loader to produce a file path first.

The response is parsed for the asset ID, and the node returns both the ID and (where available) a URL. Which output you use depends on the downstream node - most of the pack's consumers want the asset_id.

Inputs and outputs that matter

  • auth - the KLING_AUTH object from the Kling AI Authentication node. Every Kling node needs it.
  • asset_type - image or video. Sets the endpoint and what inputs are valid.
  • image - a ComfyUI IMAGE tensor (images only).
  • image_path - a path to an image file (images only; an alternative to the tensor).
  • video_path - a path to a video file (videos only - required, since there's no video tensor input here).

Outputs: asset_id (STRING) and asset_url (STRING).

How to install it

Pack-level install:

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

or "API Toolkit" in ComfyUI Manager. The Kling service needs requests and PyJWT. No downloads - this is a network call.

Common issues

The failure modes are the ones Kling's error map names directly. 1101 "invalid image" usually means the image is too large, wrong aspect ratio, or failed Kling's content check - downscale or recompose before uploading. 1102 means you're out of credits; uploads bill against the same account. And if you try to upload a video with no video_path, the node raises a clear error telling you video upload requires a file path - route a video through the pack's loaders first to get one.

Also worth knowing: uploaded assets don't live forever, and Kling tasks expire (the error map mentions 72-hour expiry on task IDs). If a workflow that worked last week fails with a "task not found"-style error, re-run the upload - assets and task IDs both rot.

CategoryAPI Toolkit/Kling AI/Config

Inputs (5)

NameTypeDefaultDescription
authKLING_AUTH
asset_typeCOMBOimageType of asset to upload.
imageoptIMAGE
image_pathoptSTRINGPath to an image file on disk.
video_pathoptSTRINGPath to a video file on disk.

Outputs (2)

NameTypeDescription
asset_idSTRING
asset_urlSTRING