promptstringbắt buộc
Describe subject, action, camera and light.
kwaivgi/kling-video/v4/text-to-videoKling V4 Text to Video by Kuaishou turns a text prompt into a 3-30 second video at 720p, 1080p or 4K.
Thử model
Bạn muốn làm gì tiếp theo?
Chọn một ví dụ để nạp đầu vào và kết quả của nó vào playground.
{
"aspect_ratio": "16:9",
"prompt": "Close-up: a single drop of water falls from the tip of a leaf into a shallow dish, creating concentric ripples. Warm window light gives the ripples a golden glow. Macro cinematography, photorealistic."
}{
"aspect_ratio": "16:9",
"prompt": "A detective in a black trench coat stands on a rooftop in the rain, looking through a telescope at the neon street below. Slow push-in, cinematic lighting."
}Kling V4 text-to-video: write a scene and get back a 3–30 second clip at 720p, 1080p or 4K.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | Up to 2,500 characters. |
aspect_ratio | 16:9 / 9:16 / 1:1 / 21:9 | 16:9 | Output frame shape. |
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.
Bắt đầu xây dựng
Gửi model này qua 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/text-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",
"aspect_ratio": "16:9",
"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"Tạo một SandBase API key và đặt nó trong môi trường máy chủ của bạn. Tất cả request sử dụng xác thực Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Giữ key trên máy chủ. Không hiển thị trong mã trình duyệt hoặc commit vào repository.
POST tới /v1/run với model ID này và các đầu vào của nó. Ví dụ request ở trên bao gồm cả bước gửi và polling.
Dùng run ID được trả về để poll cho đến khi trạng thái là completed, failed hoặc timeout. Chỉ đọc đầu ra sau khi completed.
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"Cung cấp một URL tệp có thể truy cập công khai trong trường image, video hoặc audio của model. Các định dạng và giới hạn được hỗ trợ hiển thị bên cạnh từng input trong Playground.
Dùng điều khiển upload hoặc replace trên các trường image được hỗ trợ trong Playground. Trường URL video chấp nhận một video driving được host; điều này không đồng nghĩa hỗ trợ tải lên video.
promptstringbắt buộcDescribe subject, action, camera and light.
durationintegerOutput length in seconds (3-30).
Mặc định: 5
Tối thiểu: 3
Tối đa: 30
resolutionstringOutput resolution.
Mặc định: "1080p"
Giá trị có thể dùng: "720p", "1080p", "4k"
aspect_ratiostringOutput frame shape.
Mặc định: "16:9"
Giá trị có thể dùng: "16:9", "9:16", "1:1", "21:9"
dynamic_rangestringhdr outputs 10-bit HDR video; 1080p and 4k only.
Mặc định: "sdr"
Giá trị có thể dùng: "sdr", "hdr"
{
"model": "kwaivgi/kling-video/v4/text-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",
"aspect_ratio": "16:9",
"dynamic_range": "sdr"
}Một run đã hoàn tất sẽ hiển thị kết quả trong output. Phần sau là ví dụ đã lưu của model, không phải một lần tạo mới.
[
{
"url": "https://static.sandbase.ai/examples/d9d2539c-75cd-4ee7-b7a7-ee70aa5d0db0/output/54ab6613-48ea-4b20-8c2d-c299edea2f12.mp4"
}
]