Kling 4.0
Kling 4.0
Kling 4.0 video: text or reference-to-video with images, videos, named subjects and voices, or keyframe-to-video between a first, middle and last frame, 3 to 30 seconds at 720p or 1080p
- Endpoint
- POST /api/v1/videos/generate
- model
- kling4
- Output
- Video
- Credits
- 21 per second at 720p
Отправить задачу
/api/v1/videos/generateПараметры
modelstringТребуетсяMust be "kling4"
typestringОпционально"reference-to-video" (default; text only when no references are given) or "keyframe-to-video"
reference-to-videokeyframe-to-videopromptstringТребуетсяText prompt, up to 8000 characters. Every @name must match a reference you send
durationintegerОпциональноПо умолчанию5Whole seconds, 3 to 30 (default: 5)
resolutionstringОпциональноПо умолчанию720p"720p" (default) or "1080p"
720p1080paspect_ratiostringОпциональноПо умолчаниюauto"auto" (default), "16:9", "9:16", "1:1" or "21:9"
auto16:99:161:121:9first_frame_urlstringОпциональноkeyframe-to-video: public https URL of the first frame, named @first_frame
keyframe_urlsstring[]Опциональноkeyframe-to-video: up to 8 middle frames (@keyframe_1, …). Needs first_frame_url. The total frame count is limited by duration: seconds + 1, at most 10
last_frame_urlstringОпциональноkeyframe-to-video: public https URL of the last frame, named @last_frame. May be sent without a first frame
image_urlsstring[]Опциональноreference-to-video: up to 10 reference images (@image_1, …)
video_urlsstring[]Опциональноreference-to-video: up to 5 reference videos of 2–30 seconds (@video_1, …). Reference videos and video subjects total at most 30 seconds
keep_original_soundbooleanОпциональноПо умолчаниюfalsereference-to-video: keep the sound of the reference videos (default: false)
truefalseelementsobject[]Опциональноreference-to-video: up to 7 named subjects, each { name, image_urls (2–4) or video_url (3–8 s, short side at least 700 px, character only), tag, description (up to 100 characters), voice_url }. tag is "character", "animal", "prop", "costume", "scene", "effect" or "others". Names are 1–20 characters of letters, digits, underscores or Chinese characters, and cannot be image_N, video_N, keyframe_N, audio_N, first_frame or last_frame
voicesobject[]Опциональноreference-to-video: up to 3 named voices, each { name, audio_url } (MP3 or WAV)
Запрос
curl -X POST https://www.bananapro.site/api/v1/videos/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: docs-kling4-text-001" \
-d '{
"model": "kling4",
"type": "reference-to-video",
"prompt": "A fox trots through fresh snow at sunrise, breath steaming in the cold air",
"duration": 5,
"resolution": "720p",
"aspect_ratio": "16:9"
}'Ответ200
{
"success": true,
"data": {
"task_id": "task_kling4_123",
"credits_used": 105,
"remaining_credits": 895,
"model": "kling4"
}
}Значения credits_used в этих примерах приведены для иллюстрации. Фактический расход рассчитывается при отправке и возвращается API.
Запросить задачу
/api/v1/videos/{task_id}status
pending- Accepted and waiting to start. Keep polling.
processing- Running. Keep polling.
completed- Finished. Read video_url; output holds the full result.
failed- Ended without a result. error_message says why and credits_refunded shows what was returned.
Poll every 5 to 10 seconds and stop at completed or failed, or register a webhook to be notified instead. Failed tasks are refunded automatically.
Запрос
curl https://www.bananapro.site/api/v1/videos/task_abc123 \
-H "Authorization: Bearer sk-your-api-key"Ответ200
{
"success": true,
"data": {
"task_id": "task_abc123",
"model": "kling4",
"status": "completed",
"output": { "video_url": "https://..." },
"video_url": "https://...",
"error_message": null,
"credits_used": 105,
"credits_refunded": 0,
"created_at": "2026-10-04T10:00:00.000Z",
"updated_at": "2026-10-04T10:01:12.000Z",
"completed_at": "2026-10-04T10:01:12.000Z"
},
"request_id": "req_abc123"
}Дождаться результата
TASK_ID=task_abc123
while true; do
TASK=$(curl -s https://www.bananapro.site/api/v1/videos/$TASK_ID \
-H "Authorization: Bearer sk-your-api-key")
STATUS=$(echo "$TASK" | jq -r '.data.status')
if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
echo "$TASK" | jq
break
fi
sleep 10
doneЦены
| Resolution | Without video input | With video input |
|---|---|---|
| 720p | 21 | 13 |
| 1080p | 32 | 19 |
Credits per billable second. Without video input, billable seconds are the output seconds; with a reference video or a video subject they are the output seconds plus max(input video seconds, output seconds). The length of every video is measured when you submit. POST /api/v1/quote returns the exact price without charging.
Особенности
- reference-to-video: text only, or with up to 10 images, 5 videos, 7 named subjects and 3 voices (15 references in total)
- keyframe-to-video: a first frame, up to 8 middle frames and a last frame
- 3–30 second clips at 720p or 1080p
- Name a reference in the prompt with @image_1, @video_1, @first_frame or the subject / voice name