Kling 视频
Kling 4.0
Kling 4.0 的请求参数、扣费和示例
POST
/
api
/
v1
/
task
/
submit
Kling 4.0
curl --request POST \
--url https://api.example.com/api/v1/task/submit \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/v1/task/submit"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/api/v1/task/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/task/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/task/submit"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/api/v1/task/submit")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/task/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body使用 MaxAPI 的 API 密钥提交任务。
文生视频传 0 张图片,图生视频传 1 张,首尾帧传 2 张,参考图模式传 1–10 张。省略
按秒计算总价后向上取整到整积分,1 积分等于 $0.01。比如 5 秒 720p 扣 78 积分,5 秒 1080p 扣 117 积分。
提交成功后用返回的
| 字段 | 取值 |
|---|---|
model | kling-4.0 |
input.prompt | 必填,1–5000 字符 |
input.duration | 整数 3–30 秒,默认 5 秒 |
input.resolution | 720p 或 1080p,默认 720p |
input.ratio | 16:9、9:16、1:1、21:9,默认 16:9 |
input.mode | text-to-video、image-to-video、reference-to-video 或 first-last-frame |
input.imageUrls | 可公开访问的 HTTP(S) 图片 URL,最多 10 张 |
mode 时,按 0 张、1 张、多张分别推断为文生视频、图生视频、参考图模式。当前支持文字和图片输入。
| 分辨率 | 每秒售价 | 10 秒实际扣分 |
|---|---|---|
| 720p | $0.155 | 155 积分 |
| 1080p | $0.233 | 233 积分 |
{
"model": "kling-4.0",
"input": {
"prompt": "一只纸船在清晨的池塘上漂动,镜头缓慢向前",
"resolution": "720p",
"duration": 5
}
}
data.taskId 查询状态,或设置 Webhook。确认失败(包括内容审核未通过)会全额退款。提交超时请先查任务状态。⌘I
Kling 4.0
curl --request POST \
--url https://api.example.com/api/v1/task/submit \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.example.com/api/v1/task/submit"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.example.com/api/v1/task/submit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/task/submit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/task/submit"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.example.com/api/v1/task/submit")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/task/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body