PiAPI
HomeWorkspace
HomeWorkspace
Join Discord
  1. Kling
  • Get Started
    • Overview
    • Quickstart
    • Make Instruction: How to Use PiAPI to Build a Workflow on Make?
  • Endpoints
    • Seedance
      • Less-Restriction Models Guide
      • Private Asset Library
      • Seedance 2.5
      • Seedance 2
      • Video Watermark Remover
      • Get task
    • Seedream
      • Seedream 5
      • Get Task
    • Byteaudio
      • Seed-audio
      • Get Task
    • Kling
      • Lipsync With PiAPI Kling API Examples
      • Motion Brush With PiAPI Kling API Example
      • Kling Elements Video Generation API
      • Kling Effects Video Generation
      • Cancel Task
        • Cancel Task
        • Cancel Tasks
      • Get Task
        GET
      • Create Task
        POST
      • Kling Virtual Try-On
        POST
      • Kling Effects
        POST
      • Kling Sound
        POST
      • Kling Avatar
        POST
      • Kling Motion Control
        POST
      • Kling Turbo
        POST
    • Kling omni
      • Kling o1
      • Kling 4.0 / 3.0 omni
      • Get Task
    • Minimax
      • Generate Video
      • MiniMax Speech
      • MiniMax Image
      • Get Task
    • Sora2
      • Sora2-preview Text to Video
      • Sora2 Text to Video
      • Sora2-Pro Text to Video
      • Sora2 Remove Watermark
      • Get task
    • Tools
      • File Upload API
      • Remove Background API
      • Remove Background-Get Task
      • Segment With Prompt API
      • Segment With Prompt API-Get Task
      • Image Upscale(Super Resolution) API
      • Image Upscale-Get Task
      • Video Upscale
      • Video Upscale-Get Task
      • Video Remove Background
      • Video Remove Background-Get task
      • Video Remove Subtitle
      • Video Remove Subtitle-Get task
      • Skin Tokens
      • Skin Tokens-Get task
    • Gemini
      • Gemini-2.5-flash-image
      • Nano Banana Pro
      • Nano Banana 2
      • Get task
    • GPT image
      • GPT-image API
    • LLM
      • How To Avoid Timeouts in Completion API
      • LLM API | Basic Completions
    • Omni Human
      • OmniHuman 1.5
      • Get task
    • Flux
      • Flux with LoRA and Controlnet
      • Available LoRA and Controlnet
      • Flux API with Redux Variation, Fill, Inpaint and Outpaint
      • Create Task
        • Text to Image
        • Image to Image
        • Kontext
      • Get task
    • Qwen Image
      • Text to Image
      • Image Edit
      • Get task
    • Z-Image
      • Text to Image
      • Get task
    • Faceswap
      • Multi Faceswap
      • Image Faceswap
      • Video Faceswap
      • Get Task
    • WanX
      • Generate WanX Task with LoRA Using PiAPI
      • Available LoRA Types for Wanx
      • Use Cases for Wanx LoRA
      • Use Cases for Wanx Control Camera
      • Create Task
      • Get Task
    • Wan
      • Wan2.6 Text to Video
      • Wan2.6 Image to Video
      • Get task
    • Hailuo
      • Generate Video
      • Get Task
    • Veo3
      • Veo3 Text to Video
      • Veo3 Image to Video
      • Veo3.1 Text to Video
      • Veo3.1 Image to Video
      • Get task
    • Skyreels
      • Create Task
      • Get Task
    • Framepack
      • Create Task
      • Get Task
    • Hunyuan Video
      • How to Make a Hunyuan API Call
      • Available Hunyuan Lora models
      • Get Task
      • Generate Video
    • Luma Dream Machine
      • Create Task
      • Get Task
    • Suno(service stopped)
      • Music(service stopped)
      • Lyrics(service stopped)
      • Get task
    • Song(Udio)
      • Song API Task Creation Examples
      • [Udio] Song Extend
      • Get Task
      • Create Task
      • [Udio] Generate Lyrics
    • Mmaudio
      • Get Task
      • Generate Audio
    • DiffRhythm
      • Generate Audio
      • Get Task
    • Ace Step
      • Create Task
        • Text to Audio
        • Audio to Audio
        • Audio Edit
        • Audio Extend
      • Get Task
    • TTS
      • Zeroshot Text-to-Speech F5-TTS
      • Get Task
    • Trellis
      • Trellis Create Task
      • Trellis2 Create Task
      • Get Task
    • Meshy
      • Meshy Create Task
      • Get Task
    • Pixal3D
      • Pixal3D Create Task
      • Get Task
    • Joycaption
      • Image Caption
      • Get Task
    • Midjourney
      • PiAPI Penalties on Midjourney Usage
      • Detailed Explaination on Midjourney Task Result
      • Midjourney V7 API Instructions
      • Create Task
        • Imagine
        • Upscale
        • Variation
        • Reroll
        • Describe
        • Seed
        • Blend
        • Inpaint
        • Outpaint
        • Pan
      • Cancel Task
        • Cancel Task
        • Cancel Tasks
      • Get Task
    • AI Hug
      • Get Task
      • Create Task
    • PiAPI Account Management
      • PiAPI Account Info
      • Task List Info
      • User Task History
  • Resources
    • Change Log
    • Output Storage
    • Unified API Schema
    • Webhook
    • Bulk Generation Service
    • Billings
    • PiAPI MCP Server
    • Workspace Manual
      • Host-your-account (HYA) | Back-up Account
      • Host-your-account (HYA) | Debug Checklist
      • Host-your-account (HYA) | Connected Account Status
    • Announcements
      • PiAPI 2025 January 1st Pricing Update
      • The discontinued support for midjourney
      • Sunsetting Suno
  • Schemas
    • Schemas
      • motion brush
      • Create Task
      • camera control
      • Cancel Params
      • Float2 Point
      • Control Points
      • txt2video-1.3b
      • txt2video-14b
      • txt2video-14b-lora
      • img2video-14b
      • img2video-14b-lora
      • img2video-14b-keyframe
      • img2video-14b-control-camera
      • wan22-txt2video-14b
      • wan22-img2video-14b
      • hunyuan-txt2video-lora
      • Trellis API/text-to-3D
      • Trellis API/image-to-3D
      • Trellis2 API/image-to-3D
      • Kling omni multi shot
      • VideoGenerationRequest
      • TaskRequest
      • TaskConfig
      • TaskInput
      • TaskResponse
      • ErrorResponse
    • Response
      • Unified-Task-Response
    • RequestBodies
      • Unified-Task-Request-Body
    • config
    • control_net_setting
    • lora_setting
    • VideoGenerationResponse
    • Pixal3D API/image-to-3D
  1. Kling

Create Task

POST
https://api.piapi.ai/api/v1/task
This is provided as part of the Kling API from PiAPI.
Create a Kling video with task_type: "video_generation": text-to-video, or image-to-video when image_url is set. Choose the model with version; when version is omitted, 2.6 is used. The same endpoint also creates lip_sync and effects tasks (see the end of this page).
For reference images, videos and audio, use Kling 4.0 / 3.0 omni.
INFO

Versions#

VersionOutputDuration (seconds)Notes
4.0720p / 1080p3 – 30latest model; first/last frame and keyframes
4.0-flash720p3 – 20faster, lower-cost 4.0; text or a first image
3.0720p / 1080p3 – 15multi-shots and optional native audio
3.0-turbo720p / 1080p3 – 15faster 3.0; no audio, no multi-shots
2.6 (default)std / pro5 or 10native audio in pro mode
2.5std / pro5 or 10
2.1-masterpro5 or 10always runs and is billed as pro
2.1std / pro5 or 10image-to-video only
1.6std / pro5 or 10
1.5std / pro5 or 10

Pricing#

4.0 and 3.0 (USD per second of output video)
Version720p (mode: "std")1080p (mode: "pro")
4.00.16670.25
4.0-flash0.10N/A
3.0, no audio0.100.15
3.0, with audio0.150.20
3.0-turbo0.130.19
For 4.0 / 4.0-flash the task total is rounded to the nearest cent once, after multiplying by duration.
2.6 and earlier (USD per video)
VersionMode5s10s
1.5 / 1.6 / 2.1std$0.26$0.52
1.5 / 1.6 / 2.1pro$0.46$0.92
2.1-masterpro$0.96$1.92
2.5 / 2.6std$0.20$0.39
2.5 / 2.6pro$0.33$0.66
2.6 native audio (enable_audio: true) needs mode: "pro" and costs 2× the pro price
enable_audio on versions below 2.6 is currently free and also needs mode: "pro"
Price examples
4.0, 720p, 5s: $0.83 · 10s: $1.67
4.0, 1080p, 10s: 10 * $0.25 = $2.50
4.0-flash, 720p, 10s: 10 * $0.10 = $1.00
3.0, 720p, 10s, no audio: 10 * $0.10 = $1.00
3.0, multi-shots (shot1 2s + shot2 3s), 720p with audio: (2 + 3) * $0.15 = $0.75
3.0-turbo, 1080p, 5s: 5 * $0.19 = $0.95
2.6, pro, 10s with audio: $0.33 * 2 * 2 = $1.32

Feature support#

4.04.0-flash3.03.0-turbo2.6 and earlier
Duration (seconds)3 – 303 – 203 – 153 – 155 or 10
1080p / pro (mode: "pro")✓–✓✓✓
First frame image_url✓✓✓✓✓
Last frame image_tail_url✓–✓✓pro mode only
keyframe_urls✓––––
aspect_ratio: "21:9"✓✓–––
enable_audio––✓–pro mode only
multi_shots / prefer_multi_shots––✓––
negative_prompt––✓✓✓
Cancel task––✓✓✓

Notes#

4.0 / 4.0-flash: prompt (up to 2,500 characters) and duration (integer, not clamped or defaulted) are required, including for image-to-video
4.0: first, last and keyframe images together cannot exceed 10. Images must be HTTP(S) URLs; base64 is not supported
4.0 / 4.0-flash accept only the fields marked for them above. enable_audio (even false), negative_prompt, multi-shot fields and other unlisted fields are rejected with error.code: 10003
4.0 / 4.0-flash require config.service_mode: "public"
4.0 / 4.0-flash tasks cannot be cancelled; keep polling Get Task for the final result. Creating the task again is a separate, billable task
3.0 / 3.0-turbo: duration outside 3 – 15 is clamped into that range; when omitted, 3 seconds is used (and billed). Send duration explicitly
3.0 multi_shots: the top-level prompt and duration are ignored, and the task duration (and price) is the sum of the shots. Each shot needs a prompt and 1 – 14 seconds (3 when omitted); at most 6 shots and 15 seconds in total. Otherwise the request is rejected with error.code: 10003
enable_audio: true combined with version: "3.0-turbo" is rejected with a validation error
2.6 and earlier: duration other than 5 or 10 becomes 5; aspect_ratio other than 16:9, 9:16 or 1:1 becomes 16:9
2.1: text-to-video is not available; send image_url

Response#

output.video is the video URL for every version (an empty string until the task completes). New integrations should read only this field.
3.0, 3.0-turbo, 4.0 and 4.0-flash return only output.video
2.6 and earlier, lip_sync and effects also return the legacy fields video_url, type, status and works, kept for existing integrations
Poll Get Task or set config.webhook_config; both carry the same output.

Other task types on this endpoint#

lip_sync: set origin_task_id to a completed Kling video task and local_dubbing_url (required). Text-to-speech via tts_text is currently not available. See Lipsync examples
effects: set effect. See Kling Effects

Request

Header Params

Body Params application/json

Examples
{
    "model": "kling",
    "task_type": "video_generation",
    "input": {
        "prompt": "A tree moving gently in the wind",
        "version": "4.0",
        "mode": "pro",
        "duration": 8,
        "aspect_ratio": "16:9"
    },
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "https://webhook.site/64e7e8fa-a47a-4d30-b00a-8746d2d04590",
            "secret": ""
        }
    }
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
cURL
curl --location 'https://api.piapi.ai/api/v1/task' \
--header 'x-api-key;' \
--header 'Content-Type: application/json' \
--data '{
    "model": "kling",
    "task_type": "video_generation",
    "input": {
        "prompt": "A tree moving gently in the wind",
        "version": "4.0",
        "mode": "pro",
        "duration": 8,
        "aspect_ratio": "16:9"
    },
    "config": {
        "service_mode": "public",
        "webhook_config": {
            "endpoint": "https://webhook.site/64e7e8fa-a47a-4d30-b00a-8746d2d04590",
            "secret": ""
        }
    }
}'

Responses

🟢200Success
application/json
Bodyapplication/json

Examples
{
    "code": 200,
    "data": {
        "task_id": "40680c72-279e-42c2-a4c0-e96e71865f04",
        "model": "kling",
        "task_type": "video_generation",
        "status": "pending",
        "config": {
            "service_mode": "public",
            "webhook_config": {
                "endpoint": "https://webhook.site/5468eca8-1cad-4dd3-9799-b6fbd9770fda",
                "secret": ""
            }
        },
        "input": {
            "aspect_ratio": "16:9",
            "enable_audio": true,
            "mode": "std",
            "multi_shots": [
                {
                    "duration": 3,
                    "prompt": "A dog running near the sea"
                },
                {
                    "duration": 2,
                    "prompt": "The dog stop before a cat on beach"
                }
            ],
            "prefer_multi_shots": true,
            "version": "3.0"
        },
        "output": {
            "video": ""
        },
        "meta": {
            "created_at": "2026-02-13T04:17:29.108326563Z",
            "started_at": "0001-01-01T00:00:00Z",
            "ended_at": "0001-01-01T00:00:00Z",
            "usage": {
                "type": "point",
                "frozen": 10000000,
                "consume": 0
            },
            "is_using_private_pool": false
        },
        "detail": null,
        "logs": null,
        "error": {
            "code": 0,
            "raw_message": "",
            "message": "",
            "detail": null
        }
    },
    "message": "success"
}
Modified at 2026-10-27 08:06:41
Previous
Get Task
Next
Kling Virtual Try-On