klingai-video-extension

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'.

1,868 stars

Best use case

klingai-video-extension is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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'.

Teams using klingai-video-extension should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/klingai-video-extension/SKILL.md --create-dirs "https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/main/plugins/saas-packs/klingai-pack/skills/klingai-video-extension/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/klingai-video-extension/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How klingai-video-extension Compares

Feature / Agentklingai-video-extensionStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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'.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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

```python
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 {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}

# Step 1: Generate the initial 5s video
initial = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
    "model_name": "kling-v2-master",
    "prompt": "A rocket launching from a desert landscape, cinematic",
    "duration": "5",
    "mode": "standard",
}).json()
initial_task_id = initial["data"]["task_id"]

# Wait for completion...
# (poll until task_status == "succeed")

# Step 2: Extend by 5 more seconds
extension = requests.post(f"{BASE}/videos/video-extend", headers=get_headers(), json={
    "task_id": initial_task_id,
    "prompt": "The rocket ascends through clouds into the stratosphere",
    "duration": "5",
    "mode": "standard",
}).json()
ext_task_id = extension["data"]["task_id"]

# Step 3: Poll extension task
while True:
    time.sleep(15)
    result = requests.get(
        f"{BASE}/videos/video-extend/{ext_task_id}", headers=get_headers()
    ).json()
    if result["data"]["task_status"] == "succeed":
        extended_url = result["data"]["task_result"]["videos"][0]["url"]
        print(f"Extended video: {extended_url}")
        break
    elif result["data"]["task_status"] == "failed":
        print(f"Failed: {result['data']['task_status_msg']}")
        break
```

## Chain Multiple Extensions

```python
def chain_extensions(initial_task_id: str, prompts: list[str],
                     duration: str = "5", mode: str = "standard") -> list[str]:
    """Chain multiple extensions to build a longer video."""
    current_task_id = initial_task_id
    video_urls = []

    for i, prompt in enumerate(prompts):
        print(f"Extension {i + 1}/{len(prompts)}: submitting...")

        # Submit extension
        r = requests.post(f"{BASE}/videos/video-extend", headers=get_headers(), json={
            "task_id": current_task_id,
            "prompt": prompt,
            "duration": duration,
            "mode": mode,
        }).json()
        ext_task_id = r["data"]["task_id"]

        # Poll for completion
        while True:
            time.sleep(15)
            result = requests.get(
                f"{BASE}/videos/video-extend/{ext_task_id}", headers=get_headers()
            ).json()
            status = result["data"]["task_status"]

            if status == "succeed":
                url = result["data"]["task_result"]["videos"][0]["url"]
                video_urls.append(url)
                current_task_id = ext_task_id  # next extension chains from this
                print(f"Extension {i + 1} complete: {url}")
                break
            elif status == "failed":
                raise RuntimeError(f"Extension {i + 1} failed: {result['data']['task_status_msg']}")

    return video_urls
```

## Usage: Build a 20-Second Video

```python
# Generate initial 5s
initial_r = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
    "model_name": "kling-v2-master",
    "prompt": "Morning sunrise over a mountain lake, mist rising",
    "duration": "5",
    "mode": "standard",
}).json()
initial_id = initial_r["data"]["task_id"]
# ... poll until complete ...

# Chain 3 more extensions = 5 + 5 + 5 + 5 = 20 seconds total
extensions = chain_extensions(initial_id, [
    "Sun rises higher, birds begin flying across the lake",
    "A deer approaches the water's edge to drink",
    "Wide shot pulling back to reveal the full mountain range",
])
```

## Cost

Each extension costs the same as a new generation:

| Extension Duration | Standard | Professional |
|-------------------|----------|-------------|
| 5 seconds | 10 credits | 35 credits |

A 20-second video (initial + 3 extensions) costs 40 credits in standard mode.

## Error Handling

| Error | Cause | Fix |
|-------|-------|-----|
| Invalid `task_id` | Source task doesn't exist | Verify task_id is from a completed generation |
| Source not complete | Extending a task still processing | Wait for source task to reach `succeed` status |
| Extension failed | Prompt conflict with source | Align extension prompt with original scene |

## Resources

- [Video Extension API](https://app.klingai.com/global/dev/document-api/apiReference/model/videoExtension)
- [Developer Portal](https://app.klingai.com/global/dev)

Related Skills

windsurf-extension-pack

1868
from jeremylongshore/claude-code-plugins-plus-skills

Install and configure essential Windsurf extensions for productivity. Activate when users mention "install extensions", "setup windsurf plugins", "configure extensions", "extension recommendations", or "productivity extensions". Handles extension installation and configuration. Use when working with windsurf extension pack functionality. Trigger with phrases like "windsurf extension pack", "windsurf pack", "windsurf".

klingai-webhook-config

1868
from jeremylongshore/claude-code-plugins-plus-skills

Configure webhook callbacks for Kling AI task completion. Use when building event-driven pipelines or replacing polling. Trigger with phrases like 'klingai webhook', 'kling ai callback', 'klingai notifications', 'video completion webhook'.

klingai-usage-analytics

1868
from jeremylongshore/claude-code-plugins-plus-skills

Build usage analytics and reporting for Kling AI video generation. Use when tracking patterns, analyzing costs, or building dashboards. Trigger with phrases like 'klingai analytics', 'kling ai usage report', 'klingai metrics', 'video generation stats'.

klingai-upgrade-migration

1868
from jeremylongshore/claude-code-plugins-plus-skills

Migrate between Kling AI model versions safely. Use when upgrading from v1.x to v2.x or adopting new features. Trigger with phrases like 'klingai upgrade', 'kling ai migrate', 'klingai version update', 'upgrade kling model'.

klingai-text-to-video

1868
from jeremylongshore/claude-code-plugins-plus-skills

Generate videos from text prompts with Kling AI. Use when creating videos from descriptions, learning prompt techniques, or building T2V pipelines. Trigger with phrases like 'kling ai text to video', 'klingai prompt', 'generate video from text', 'text2video kling'.

klingai-team-setup

1868
from jeremylongshore/claude-code-plugins-plus-skills

Configure Kling AI for teams with per-project API keys, usage quotas, and role-based access. Trigger with phrases like 'klingai team', 'kling ai organization', 'klingai multi-user', 'shared klingai access'.

klingai-style-transfer

1868
from jeremylongshore/claude-code-plugins-plus-skills

Apply artistic styles and visual effects to Kling AI video generation. Use when creating stylized content or using effects API. Trigger with phrases like 'klingai style', 'kling ai effects', 'klingai artistic video', 'stylize klingai video'.

klingai-storage-integration

1868
from jeremylongshore/claude-code-plugins-plus-skills

Download and store Kling AI generated videos in cloud storage (S3, GCS, Azure). Use when persisting videos or building CDN pipelines. Trigger with phrases like 'klingai storage', 'save klingai video', 'kling ai s3 upload', 'klingai cloud storage'.

klingai-sdk-patterns

1868
from jeremylongshore/claude-code-plugins-plus-skills

Production SDK patterns for Kling AI: client wrapper, retry logic, async polling, and error handling. Use when building robust integrations. Trigger with phrases like 'klingai sdk', 'kling ai client', 'klingai patterns', 'kling ai wrapper'.

klingai-reference-architecture

1868
from jeremylongshore/claude-code-plugins-plus-skills

Production reference architecture for Kling AI video generation platforms. Use when designing scalable systems. Trigger with phrases like 'klingai architecture', 'kling ai system design', 'video platform architecture', 'klingai production setup'.

klingai-rate-limits

1868
from jeremylongshore/claude-code-plugins-plus-skills

Handle Kling AI API rate limits with backoff and queuing strategies. Use when hitting 429 errors or planning high-volume workflows. Trigger with phrases like 'klingai rate limit', 'kling ai 429', 'klingai throttle', 'kling api limits'.

klingai-prod-checklist

1868
from jeremylongshore/claude-code-plugins-plus-skills

Production readiness checklist for Kling AI integrations. Use before going live or during deployment review. Trigger with phrases like 'klingai production ready', 'kling ai go live', 'klingai checklist', 'deploy klingai'.