Nodes/ComfyUI API Toolkit/Kling Image Extend
ComfyUI Node

Kling Image Extend

Outpaint your images with Kling instead of fighting the edge yourself

By IxMxAMAR·Created 5 months ago·Updated 2 months ago· 1
Kling Image Extend
  • auth
  • image
  • image
  • url
  • task_id
image_id
prompt
aspect_ratio1:1

You've got a square image and you need a 16:9 version of the same scene - not a crop, not a stretched mess, but a believable extension where the model figures out what's plausibly outside the frame. That's "image extend," and this node is Kling's version of it. Where the local outpainting story is "mask the edge and hope the sampler cooperates," Kling just regenerates the whole thing at a new aspect ratio and invents coherent content for the added area. You reach for it when you're preparing storyboards, reframing an asset for a different platform, or rescuing a composition that's too tight.

Mechanically it's a cloud generation task: the node takes your auth, the image_id of the asset you're extending, a prompt describing what the extended area should be, and a target aspect_ratio (16:9, 9:16, 1:1, 3:2, 2:3, 4:3, or 3:4). It submits the task and polls until it's done - the same submit-and-poll loop every generation node in this pack uses, with the pack's retry-and-backoff logic handling transient hiccups.

Inputs that actually matter:

  • image_id - the asset ID of the image to extend, typically from a previous Kling generation. There's also an optional image input; wire in a fresh IMAGE and the pack can use it directly if you don't have an ID handy.
  • prompt - describe what should appear in the newly-created area, or leave it sparse and let Kling continue the scene on its own.
  • aspect_ratio - this is what determines how much new content you're asking for. Going 1:1 → 16:9 is a big lateral extension; going the other way adds sky and foreground.

Outputs are the standard image-trio: image (a ComfyUI IMAGE tensor you can preview or feed into a save node), url (the hosted result, handy if you're chaining into another cloud call), and task_id for tracking.

Installing it

Part of ComfyUI-API-Toolkit. Manager: search "API Toolkit". Or:

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

Restart ComfyUI. Kling service needs requests and PyJWT.

Gotchas

Remember this is a per-call API - every extension is a new generation, and long extensions at high resolution add up fast on Kling credits. And it's a reimagining, not a pixel-perfect preserve-and-fill: Kling keeps the composition but details in the extended region are invented, so text and faces at the new edge can drift. For close-up faces, run the extended result through a local detail pass rather than trusting it cold. The standard Kling error map applies - error 1101 for an invalid image (too large or wrong aspect), 1102 if you're out of credits, 1302 if the content trips the safety filter. All of them print with a readable hint instead of a bare code.

CategoryAPI Toolkit/Kling AI/Image

Inputs (5)

NameTypeDefaultDescription
authKLING_AUTH
image_idSTRINGAsset ID of the image to extend.
promptSTRINGPrompt for the extended area.
aspect_ratioCOMBO1:1Target aspect ratio for the extended image.
imageoptIMAGE

Outputs (3)

NameTypeDescription
imageIMAGE
urlSTRING
task_idSTRING