imagestring必填
First frame. Min 300x300 px, aspect ratio 0.4-2.5, up to 30 MB.
kwaivgi/kling-video/v4/image-to-videoKling V4 Image to Video by Kuaishou animates a start image, optionally toward an end image, into a 3-30 second video.
试用该模型
PNG、JPEG、WebP 或 GIF · 最大 20 MiB
PNG、JPEG、WebP 或 GIF · 最大 20 MiB
下一步想做什么?
选择一个示例,将其输入和结果加载到 playground 中。
{
"image": "https://static.sandbase.ai/examples/746c1af3-e60b-4a50-a599-53df4d3da1ae/input/fae6ad50-5dc0-4015-8e2f-4ff7689f448b.png",
"prompt": "The rabbit looks around curiously, its ears twitch, then it hops toward the camera. Soft breeze moves the grass."
}{
"image": "https://static.sandbase.ai/examples/2346d3f9-1129-4a8c-a0d9-60eb2b488e9c/input/7b330c7f-26f4-4038-8198-34fc2d98051e.png",
"prompt": "The tiger slowly turns its head toward the camera and lets out a low growl, slow cinematic dolly-in."
}Kling V4 image-to-video animates a start image, optionally toward an end image, into a 3–30 second clip.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | Up to 2,500 characters. |
image | image URL, required | — | First frame. Min 300×300 px, aspect ratio 0.4–2.5, up to 30 MB. |
end_image | image URL | — | Optional last frame. |
resolution | 720p / 1080p / 4k | 1080p | Output resolution. |
dynamic_range | sdr / hdr | sdr | hdr outputs 10-bit HDR video. 1080p and 4k only. |
duration | 3–30 | 5 | Output length in seconds. |
Billed per output second: $0.157 at 720p, $0.235 at 1080p, $0.549 at 4K. HDR adds $0.047 per output second at 1080p and $0.078 at 4K.
| Output | Price |
|---|---|
| 5s, 1080p (default) | $1.175 |
| 5s, 720p | $0.785 |
| 5s, 4K | $2.745 |
| 5s, 4K, HDR | $3.135 |
| 10s, 1080p | $2.35 |
| 30s, 1080p | $7.05 |
| Failed runs are not charged. |
Other Kling V4 endpoints: kwaivgi/kling-video/v4/text-to-video, kwaivgi/kling-video/v4/image-to-video, kwaivgi/kling-video/v4/reference-to-video, kwaivgi/kling-video/v4/video-edit.
开始构建
通过 SandBase Unified Run API 提交此模型。
# The quoted heredoc keeps Unicode and shell metacharacters unchanged.
result=$(curl --fail-with-body --silent \
-X POST "https://api.sandbase.ai/v1/run" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'SANDBASE_JSON'
{
"model": "kwaivgi/kling-video/v4/image-to-video",
"prompt": "A detective in a black trench coat stands on a rooftop in the rain, looking through a telescope at the street below.",
"duration": 5,
"resolution": "1080p",
"dynamic_range": "sdr"
}
SANDBASE_JSON
)
run_id=$(printf '%s' "$result" | jq -r .id)
for attempt in $(seq 1 120); do
status=$(printf '%s' "$result" | jq -r .status)
case "$status" in completed|failed|timeout) break ;; esac
sleep 2
result=$(curl --fail-with-body --silent \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
"https://api.sandbase.ai/v1/run/$run_id")
done
status=$(printf '%s' "$result" | jq -r .status)
[ "$status" = completed ] || { echo "Generation ended: $status" >&2; exit 1; }
printf '%s\n' "$result"创建一个 SandBase API 密钥,并将其设置到服务器环境中。所有请求都使用 Bearer 身份验证。
export SANDBASE_API_KEY="YOUR_API_KEY"请将密钥保存在服务器端。不要在浏览器代码中暴露它,也不要提交到仓库。
使用此模型 ID 及其输入向 /v1/run 发送 POST 请求。上方的请求示例包含提交和轮询。
使用返回的运行 ID 轮询,直到状态为 completed、failed 或 timeout。仅在 completed 后读取输出。
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"在模型的 image、video 或 audio 字段中传入一个可公开访问的文件 URL。支持的格式和限制显示在每个 Playground 输入项旁边。
在 Playground 中支持的图片字段上使用上传或替换控件。视频 URL 字段接受托管的 driving video;这并不表示支持视频上传。
imagestring必填First frame. Min 300x300 px, aspect ratio 0.4-2.5, up to 30 MB.
promptstring必填Describe subject, action, camera and light.
durationintegerOutput length in seconds (3-30).
默认值:5
最小值:3
最大值:30
end_imagestringOptional last frame.
resolutionstringOutput resolution.
默认值:"1080p"
可选值:"720p", "1080p", "4k"
dynamic_rangestringhdr outputs 10-bit HDR video; 1080p and 4k only.
默认值:"sdr"
可选值:"sdr", "hdr"
{
"model": "kwaivgi/kling-video/v4/image-to-video",
"prompt": "A detective in a black trench coat stands on a rooftop in the rain, looking through a telescope at the street below.",
"duration": 5,
"resolution": "1080p",
"dynamic_range": "sdr"
}已完成的运行会在输出中展示结果。以下内容是该模型保存的示例,而不是新的生成结果。
[
{
"url": "https://static.sandbase.ai/examples/746c1af3-e60b-4a50-a599-53df4d3da1ae/output/f9326313-f618-476e-bc14-075875ae2ed8.mp4"
}
]