| name | klingai-video-extension |
| description | Extend video duration using Kling AI continuation. Use when creating longer videos from
shorter clips or building sequences. Trigger with phrases like 'klingai extend video',
'kling ai video continuation', 'klingai longer video', 'extend klingai clip'.
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.18.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","kling-ai","video-extension","continuation"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Kling AI Video Extension
Overview
Extend an existing video by appending additional seconds. The extension endpoint takes the task_id of a completed video and generates a seamless continuation.
Endpoint: POST https://api.klingai.com/v1/videos/video-extend
Request Parameters
| Parameter | Type | Required | Description |
|---|
task_id | string | Yes | Task ID of the completed source video |
prompt | string | No | Motion/scene description for extension |
duration | string | No | Extension length: "5" (default) |
mode | string | No | "standard" or "professional" |
model_name | string | No | Default: "kling-v2-master" |
callback_url | string | No | Webhook for completion |
Basic Extension
import jwt, time, os, requests
BASE = "https://api.klingai.com/v1"
def get_headers():
ak, sk = os.environ["KLING_ACCESS_KEY"], os.environ["KLING_SECRET_KEY"]
token = jwt.encode(
{"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5},
sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}
)
return {: , : }
initial = requests.post(, headers=get_headers(), json={
: ,
: ,
: ,
: ,
}).json()
initial_task_id = initial[][]
extension = requests.post(, headers=get_headers(), json={
: initial_task_id,
: ,
: ,
: ,
}).json()
ext_task_id = extension[][]
:
time.sleep()
result = requests.get(
, headers=get_headers()
).json()
result[][] == :
extended_url = result[][][][][]
()
result[][] == :
()