Kling
延长一个 Kling 视频
通过 POST /kling/v1/videos/video-extend 使用 task_id 和 video_id 延长 Kling 生成的视频;作为父账户下的子任务运行。
POST
/
kling
/
v1
/
videos
/
video-extend
cURL
curl https://api.cometapi.com/kling/v1/videos/video-extend \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/video-extend",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/video-extend", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/video-extend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_id' => '<parent_task_id>',
'video_id' => '<video_id>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/video-extend"
payload := strings.NewReader("{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/video-extend")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/video-extend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"request_id": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"task_status_msg": "<string>",
"task_info": {
"parent_video": {
"id": "<string>",
"url": "<string>",
"duration": "<string>"
}
},
"task_result": {
"videos": [
{
"id": "<string>",
"url": "<string>",
"duration": "<string>"
}
]
},
"created_at": 123,
"updated_at": 123
}
}使用此端点可将现有的 Kling 视频作为后续任务进行延长。
调用前准备
- 从一个已完成的 Kling 视频结果开始
- 传入父任务结果中的
video_id - 将父
task_id与video_id一起传入 - 使用与延长兼容的源视频;不受支持的源视频会返回 HTTP 400,而不是创建延长任务
- 已完成的 5 秒 Kling v1 或 v1-6 文生视频或图生视频父任务,是更稳妥的延长兼容性起点
- 仅在需要引导续写内容时添加
prompt、negative_prompt或cfg_scale - 在与父任务相同的账户上下文中运行延长任务
- 在父任务资源过期前尽快触发延长
任务流程
1
完成父视频任务
创建原始 Kling 视频,并等待其结果可用。
2
提交延长请求
发送父
task_id、video_id 和可选 prompt,然后保存返回的任务 id。3
轮询延长任务
继续使用获取一个 Kling 任务,直到延长后的视频达到终态。
完整的参数参考请见官方 Kling 文档。
请求体
application/json
最后修改于 2026年6月25日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/video-extend \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/video-extend",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/video-extend", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"task_id": "<parent_task_id>",
"video_id": "<video_id>",
"prompt": "Continue with the same calm morning atmosphere",
"cfg_scale": 0.5
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/kling/v1/videos/video-extend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'task_id' => '<parent_task_id>',
'video_id' => '<video_id>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/kling/v1/videos/video-extend"
payload := strings.NewReader("{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/kling/v1/videos/video-extend")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/kling/v1/videos/video-extend")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"task_id\": \"<parent_task_id>\",\n \"video_id\": \"<video_id>\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"request_id": "<string>",
"data": {
"task_id": "<string>",
"task_status": "<string>",
"task_status_msg": "<string>",
"task_info": {
"parent_video": {
"id": "<string>",
"url": "<string>",
"duration": "<string>"
}
},
"task_result": {
"videos": [
{
"id": "<string>",
"url": "<string>",
"duration": "<string>"
}
]
},
"created_at": 123,
"updated_at": 123
}
}