cURL
curl https://api.apipod.ai/v1/videos/generations \
-H "Authorization: Bearer $APIPOD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}'import os
import requests
payload = {
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}
response = requests.post(
"https://api.apipod.ai/v1/videos/generations",
headers={
"Authorization": f"Bearer {os.environ['APIPOD_API_KEY']}",
"Content-Type": "application/json",
},
json=payload,
timeout=60,
)
response.raise_for_status()
print(response.json())package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}`)
req, err := http.NewRequest(http.MethodPost, "https://api.apipod.ai/v1/videos/generations", bytes.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("APIPOD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}use reqwest::Client;
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let payload = json!({
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
});
let response = Client::new()
.post("https://api.apipod.ai/v1/videos/generations")
.bearer_auth(env::var("APIPOD_API_KEY")?)
.json(&payload)
.send()
.await?
.error_for_status()?;
println!("{}", response.text().await?);
Ok(())
}const response = await fetch("https://api.apipod.ai/v1/videos/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.APIPOD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}),
});
if (!response.ok) {
throw new Error(`APIPod request failed: ${response.status} ${await response.text()}`);
}
console.log(await response.json());{
"code": 200,
"message": "success",
"data": {
"task_id": "vid_task_01JEXAMPLE"
}
}Kling 4.0
Kling 4.0 图生视频
Kling 4.0 I2V 是 APIPod 面向可灵 Kling 4.0 提供的关键帧图生视频模式,按首帧、最多 8 张中间帧与可选尾帧生成 3-30 秒视频。
POST
https://api.apipod.ai
/
v1
/
videos
/
generations
cURL
curl https://api.apipod.ai/v1/videos/generations \
-H "Authorization: Bearer $APIPOD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}'import os
import requests
payload = {
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}
response = requests.post(
"https://api.apipod.ai/v1/videos/generations",
headers={
"Authorization": f"Bearer {os.environ['APIPOD_API_KEY']}",
"Content-Type": "application/json",
},
json=payload,
timeout=60,
)
response.raise_for_status()
print(response.json())package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}`)
req, err := http.NewRequest(http.MethodPost, "https://api.apipod.ai/v1/videos/generations", bytes.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("APIPOD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(resp.Status, string(out))
}use reqwest::Client;
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let payload = json!({
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
});
let response = Client::new()
.post("https://api.apipod.ai/v1/videos/generations")
.bearer_auth(env::var("APIPOD_API_KEY")?)
.json(&payload)
.send()
.await?
.error_for_status()?;
println!("{}", response.text().await?);
Ok(())
}const response = await fetch("https://api.apipod.ai/v1/videos/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.APIPOD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "kling-4.0-i2v",
"prompt": "The girl in @first_frame walks out, passes the street in @keyframe_1 and arrives at the party in @last_frame.",
"image_urls": [
"https://cdn.example.com/first.png",
"https://cdn.example.com/last.png"
],
"keyframe_urls": [
"https://cdn.example.com/street.png"
],
"duration": 10,
"resolution": "720p"
}),
});
if (!response.ok) {
throw new Error(`APIPod request failed: ${response.status} ${await response.text()}`);
}
console.log(await response.json());{
"code": 200,
"message": "success",
"data": {
"task_id": "vid_task_01JEXAMPLE"
}
}使用说明
- 帧:
image_urls[0]为必填的首帧,可选的image_urls[1]为尾帧;中间帧按时间顺序放在keyframe_urls(最多 8 张)。输出画幅跟随首帧,因此不接受aspect_ratio。 - 帧数上限:帧总数(首帧 + 中间帧 + 尾帧)受
duration限制:3 秒 4 帧、4 秒 5 帧、5 秒 6 帧、6 秒 7 帧、7 秒 8 帧、8 秒 9 帧,9 秒及以上 10 帧。超出上限会在创建任务前直接返回 400。 - 引用帧:在 prompt 中用
@first_frame、@keyframe_1..@keyframe_N、@last_frame描述各帧发生的内容,只能引用实际提供的帧。 - 音频:每段视频都带原生音频,因此没有
generate_audio参数,传入会被拒绝。 - 不支持:
negative_prompt、multi_shot/multi_prompt、参考视频、kling_elements、voices与 4K 输出。
计费
按输出视频时长逐秒计费,每秒费率按分辨率(720p / 1080p)区分,与帧数无关。具体价格以 模型页 展示为准。任务流程
创建请求返回data.task_id。使用查询视频任务轮询,直到 status 变为 completed(结果位于 data.result)或 failed;也可以传入 callback_url,在任务进入终态时接收通知。授权
在 Authorization 请求头中使用 Bearer APIPod_API_KEY。
请求体
application/json
APIPod 公开模型 ID。
Allowed value:
"kling-4.0-i2v"必填,最多 8000 字。可用 @first_frame、@keyframe_1..@keyframe_N、@last_frame 引用已上传的帧;只能引用实际提供的帧,否则请求会被拒绝。
Required string length:
1 - 8000必填。image_urls[0] 为首帧,可选的 image_urls[1] 为尾帧;中间帧请放在 keyframe_urls。输出画幅跟随首帧。也接受 first_frame_image / last_frame_image 别名。
Required array length:
1 - 2 elements可选的中间帧,按时间顺序排列(最多 8 张),以 @keyframe_1..@keyframe_N 引用。需要先提供首帧;帧总数受 duration 限制。
Maximum array length:
8输出时长(秒),3-30,默认 5。同时限制帧总数(首帧 + 中间帧 + 尾帧):3 秒 4 帧、4 秒 5 帧、5 秒 6 帧、6 秒 7 帧、7 秒 8 帧、8 秒 9 帧,9 秒及以上 10 帧。
必填范围:
3 <= x <= 30输出分辨率,默认 720p。Kling 4.0 不提供 4K。
可用选项:
720p, 1080p 接收任务终态通知的 HTTPS 地址。
此页面对您有帮助吗?