Kling 文生视频
curl --request POST \
--url https://kaienapi.com/kling/v1/videos/text2video \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "kling-v2-master",
"prompt": "一支科技产品展示短片,镜头平稳推进,灯光干净",
"duration": 5,
"mode": "pro",
"aspect_ratio": "16:9"
}
'import requests
url = "https://kaienapi.com/kling/v1/videos/text2video"
payload = {
"model": "kling-v2-master",
"prompt": "一支科技产品展示短片,镜头平稳推进,灯光干净",
"duration": 5,
"mode": "pro",
"aspect_ratio": "16:9"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'kling-v2-master',
prompt: '一支科技产品展示短片,镜头平稳推进,灯光干净',
duration: 5,
mode: 'pro',
aspect_ratio: '16:9'
})
};
fetch('https://kaienapi.com/kling/v1/videos/text2video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/kling/v1/videos/text2video"
payload := strings.NewReader("{\n \"model\": \"kling-v2-master\",\n \"prompt\": \"一支科技产品展示短片,镜头平稳推进,灯光干净\",\n \"duration\": 5,\n \"mode\": \"pro\",\n \"aspect_ratio\": \"16:9\"\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))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Kling 文生视频
Kling 文生视频接口,按文本描述创建视频任务。
请求格式
使用 application/json。常见字段包括 model、prompt、duration、mode 和 aspect_ratio。
读取结果
创建成功后返回任务信息或任务 ID。后续使用查询接口获取状态和最终视频结果。
错误定位
- 参数不生效:确认字段名是否与模型说明一致。
- 画幅不符合预期:检查
aspect_ratio或尺寸参数。 - 任务失败:保留返回错误信息,提示用户调整 prompt 或参数。
POST
/
kling
/
v1
/
videos
/
text2video
Kling 文生视频
curl --request POST \
--url https://kaienapi.com/kling/v1/videos/text2video \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "kling-v2-master",
"prompt": "一支科技产品展示短片,镜头平稳推进,灯光干净",
"duration": 5,
"mode": "pro",
"aspect_ratio": "16:9"
}
'import requests
url = "https://kaienapi.com/kling/v1/videos/text2video"
payload = {
"model": "kling-v2-master",
"prompt": "一支科技产品展示短片,镜头平稳推进,灯光干净",
"duration": 5,
"mode": "pro",
"aspect_ratio": "16:9"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'kling-v2-master',
prompt: '一支科技产品展示短片,镜头平稳推进,灯光干净',
duration: 5,
mode: 'pro',
aspect_ratio: '16:9'
})
};
fetch('https://kaienapi.com/kling/v1/videos/text2video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/kling/v1/videos/text2video"
payload := strings.NewReader("{\n \"model\": \"kling-v2-master\",\n \"prompt\": \"一支科技产品展示短片,镜头平稳推进,灯光干净\",\n \"duration\": 5,\n \"mode\": \"pro\",\n \"aspect_ratio\": \"16:9\"\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))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Authorizations
在请求头中传入:Authorization: Bearer sk-...
Body
application/json
The body is of type object.
Response
任务结果
The response is of type object.
⌘I