Kling V4
Generate 3–30 second videos at 720p or 1080p with generated audio, from text, frames in time order, or reference images, videos, voices and named elements; billed per second.
- Asynchronous: the create call returns a task ID; the video arrives when the task succeeds.
- Four ways in: text only, frames (
imagesin time order), reference images, videos and voices, and up to seven namedelements. Frames cannot be combined with references or elements. - Name every input in the prompt:
@image_1,@video_1,@voice_1,@plus an element name,@first_frame,@keyframe_1and@last_frame. Every@must name an input of the same request. - Audio is always generated.
keep_original_soundkeeps the reference videos’ own sound instead. durationruns from 3 to 30 seconds (5 by default) at720p(the default) or1080p. Billed per second at the resolution you choose; a failed task costs nothing.
Opens this model in the API Explorer. Enter your BeatAPI API key to create a task: the call is real and is billed to your own balance.
Model IDs
Two Kling generation models share this endpoint. The values below come straight from the gateway contract; only Kling V4 takes reference inputs, more than two frames and up to seven elements.
Endpoint and authentication
POST https://api.beatapi.io/v1/videos/tasks
Authorization
string
Required
Your BeatAPI API key, sent as Bearer <BEATAPI_API_KEY>. Create keys in the Dashboard. Keep keys on your server; never ship them in a browser or mobile app.
Send the body as JSON with Content-Type: application/json. Idempotency-Key is optional: send a unique value (at most 255 characters) per logical request and reuse it only to retry that exact body. Within 24 hours a retry with the same key and body returns the first response again with Idempotent-Replayed: true; the same key with a different body returns 409 idempotency_conflict. Responses other than 2xx are not stored, so a retry after a 400 or 402 runs again.
How a request works
Create the task
POST the parameters below to the endpoint. A 201 means the task was accepted and its price reserved from your balance; the work runs in the background. Save data.id.
Wait for it to finish
Call GET /v1/tasks/{task_id} and wait data.poll_after_seconds between calls (5 s for images, 8 s for videos) until status is succeeded or failed. Or register a webhook for task.succeeded and task.failed; keep polling as the fallback, because a task stopped by the processing timeout sends no event.
Save the result
On succeeded, download every data.output.media[].url and store the files you need; BeatAPI does not promise how long result URLs stay available. On failed, read data.error_code and data.error_message: the reserved amount was returned to your balance, and data.retryable says whether sending the same request again can succeed.
Input modes
Request parameters
model
string
Required
The model to run.
Value: kling-v4
If the value is wrong
- Missing:
"model" is required - An image model sent to this endpoint:
"model" nano-banana-2 is served by POST /v1/images/tasks, not this endpoint
prompt
string
Required
What happens in the video: subject, action, camera movement, style and sound, with each input named by its @ mention.
Length: 1–5000 characters
- Length is counted in characters (a CJK character counts as one).
- Mentions:
reference_imagesare@image_1,@image_2…,reference_videosare@video_1…,reference_audiosare@voice_1…, and an element is@followed by itsname. Frames are@first_frame,@keyframe_1,@keyframe_2… and@last_frame. - Every
@must name an input of the same request. A numbered or frame mention with nothing behind it, such as@image_3with two reference images or@last_framewith one image, is refused when the task is created.
If the value is wrong
- Missing:
"prompt" is required - Empty or longer than the limit:
"prompt" has an unsupported length - A mention of an input the request does not send:
the prompt names @image_3, which this request does not send
images
string[]
Optional
Frames in time order: one link is the first frame, two are the first and last frame, and more add middle frames between them.
Items: 1–10
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- With three or more links,
images[0]is the first frame and the last link the last frame; the links in between are middle frames, soimages[1]is@keyframe_1,images[2]is@keyframe_2, and so on. - A video takes at most one image more than its seconds (
duration+ 1, counting 5 seconds whendurationis left out), and never more than 10. - Frames cannot be sent with
reference_images,reference_videos,reference_audios,elementsoraspect_ratio: the video takes the shape of the first frame.
If the value is wrong
- More than 10 links:
"images" accepts at most 10 items - More links than
duration+ 1 (here 7 links for a 5-second video):Kling V4 takes at most 6 images for a 5-second video - Combined with any reference_* field:
Cannot combine "images" with reference inputs in one task - Combined with
elements:Kling V4 cannot combine elements with images - Combined with
aspect_ratio:Kling V4 takes the first frame's shape; do not send aspect_ratio with images - Not an https:// link:
"images[0]" must be a public HTTPS URL
reference_images
string[]
Optional
Pictures that guide the content, characters, products or style of the video. Name them in the prompt as @image_1, @image_2 … in list order.
Items: 1–10
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Cannot be combined with
images. - Count toward the limit of 15 reference inputs and elements together.
If the value is wrong
- More than the maximum:
"reference_images" accepts at most 10 items - More than 15 reference inputs and elements together:
Kling V4 takes at most 15 reference inputs and elements together
reference_videos
string[]
Optional
Videos to take motion, camera work or content from. Name them in the prompt as @video_1, @video_2 … in list order.
Items: 1–5
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Each clip runs 2 to 30 seconds, and all clips together at most 30 seconds. The gateway measures each clip before creating the task and refuses one outside these limits, naming it.
- Reference videos and video elements together are at most 5, and count toward the limit of 15 reference inputs and elements.
- The finished video has generated audio unless you send
keep_original_sound: true, which keeps the reference videos’ own sound.
If the value is wrong
- More than the maximum:
"reference_videos" accepts at most 5 items - A clip shorter than 2 or longer than 30 seconds:
reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds. - Clips that run longer than 30 seconds together:
The reference videos run 36 seconds in total; this model takes at most 30. - More than 5 reference videos and video elements together:
Kling V4 takes at most 5 reference videos and video elements together
reference_audios
string[]
Optional
Voices for the video. Name them in the prompt as @voice_1, @voice_2 … in list order.
Items: 1–3
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Cannot be combined with
images. - Count toward the limit of 15 reference inputs and elements together.
If the value is wrong
- More than the maximum:
"reference_audios" accepts at most 3 items
elements
object[]
Optional
Up to seven named subjects, such as a character, an animal, a prop, a costume, a scene or an effect, each defined once and named in the prompt as @ followed by its name.
Items: ≤ 7
- An array of at most seven objects. Each object accepts these keys and no others:
elements[].name(string, required): 1 to 20 letters, digits, underscores or Chinese characters, unique within the request ignoring case. It cannot beimage_N,video_N,voice_N,keyframe_N,object_N,audio_N,first_frameorlast_frame.elements[].element_input_urls(array of strings): 2 to 4 public HTTPS links to pictures of the element; the first is its main view.elements[].element_input_video_urls(array of strings): exactly one public HTTPS link to a 3 to 8 second single-shot video of a character. Send this orelement_input_urls, not both.elements[].element_input_audio_urls(array of strings, optional): exactly one public HTTPS audio link, the voice of a character element.elements[].tag(string, optional): what the element is. A video element, or an element with a voice, must be a character: leavetagout or sendcharacter.elements[].description(string, optional): what the element is, at most 100 characters.- Video elements are at most 3, and at most 5 together with
reference_videos. Every element counts toward the limit of 15 reference inputs and elements. - Elements cannot be sent with
images.
If the value is wrong
- More than seven elements:
"elements" accepts at most 7 items - An element that is not an object:
"elements[0]" must be an object - An element without
name:"name" is required in "elements[0]" - A
namethat is empty or longer than 20:"elements[0].name" has an unsupported length - A
namewith other characters, or a reserved name:elements[0].name "image_1" is not a name Kling V4 accepts - The same
nametwice, ignoring case:elements[1].name "Hero" is used twice - Both pictures and a video, or neither:
elements[0] takes either element_input_urls or element_input_video_urls - Fewer than two pictures:
"elements[0].element_input_urls" requires at least 2 item - More than four pictures:
"elements[0].element_input_urls" accepts at most 4 items - A video element whose
tagis notcharacter:elements[0] is a video element, which is always a character - A voice on an element whose
tagis notcharacter:elements[0] has a voice, which only a character element takes - A
tagnot in the list:"elements[0].tag" must be one of: [character animal prop costume scene effect others] - A
descriptionlonger than 100 characters:"elements[0].description" has an unsupported length - A key that an element does not accept:
field "start_time" is not supported in "elements[0]" - More than three video elements:
Kling V4 takes at most 3 video elements - Combined with
images:Kling V4 cannot combine elements with images
duration
integer
OptionalDefault: 5
Length of the video in seconds, a whole number. It is what you are billed for.
Default: 5
Range: 3–30
- If you leave it out,
5is used and billed. - With frames it also caps the number of images: at most
duration+ 1, and never more than 10.
If the value is wrong
- Outside the range, not a whole number, or sent as a string:
"duration" is outside its supported range
aspect_ratio
string
OptionalDefault: 16:9
Shape of the video as width:height.
Allowed values: 16:9, 9:16, 1:1, 21:9
Default: 16:9
- If you leave it out,
16:9is used. - Do not send it with
images: the video takes the shape of the first frame.
If the value is wrong
- A value not in the list:
"aspect_ratio" must be one of: [16:9 9:16 1:1 21:9] - Sent with
images:Kling V4 takes the first frame's shape; do not send aspect_ratio with images
resolution
string
OptionalDefault: 720p
Output resolution. 1080p costs more per second than 720p.
Allowed values: 720p, 1080p
Default: 720p
- If you leave it out,
720pis used and billed. - 4K is not available on this model.
If the value is wrong
- A value not in the list (for example
4Korpro):"resolution" must be one of: [720p 1080p]
keep_original_sound
boolean
Optional
Keeps the reference videos’ own sound in the finished video instead of generated audio.
- Only valid with
reference_videos; sending it without them, even asfalse, is refused. - Without it the video comes with generated audio. There is no field that turns audio off.
If the value is wrong
- Not true or false:
"keep_original_sound" must be a boolean - Sent without
reference_videos:"keep_original_sound" needs reference_videos
The gateway also checks these combinations before creating the task:
- images cannot be combined with reference inputs
- images are frames in time order: one is the first frame, two the first and last, more add middle frames between them; the prompt names them @first_frame, @keyframe_1, @keyframe_2 … and @last_frame
- a video takes at most one image more than its seconds, and never more than 10
- the prompt names reference_images as @image_1, @image_2 …, reference_videos as @video_1 …, reference_audios as @voice_1 … and elements as @ followed by their name; every @ in the prompt must name an input of the same request
- reference videos run 2-30 seconds each and 30 seconds together; reference videos and video elements are at most 5 together, video elements at most 3; reference_images, reference_videos, reference_audios and elements are at most 15 together
- an element is 2-4 images in element_input_urls, the first its main view, or one 3-8 second single-shot character video in element_input_video_urls; element_input_audio_urls gives a character element its voice
- element names are 1-20 letters, digits, underscores or Chinese characters, unique ignoring case, and not image_N, video_N, voice_N, keyframe_N, object_N, audio_N, first_frame or last_frame
- elements and aspect_ratio cannot be sent with images: the output takes the first frame’s shape; without images aspect_ratio defaults to 16:9
- keep_original_sound keeps the reference videos’ own audio and needs reference_videos; otherwise the video comes with generated audio
Input media limits
The gateway reads every input before the task is created and refuses one outside these limits with a 400 bad_request that names the input. Nothing is charged.
- The gateway measures
images,reference_imagesandreference_videosbefore the task is created and refuses an input outside these limits with a message that names it by list and position, for examplereference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds.Nothing is charged. - Element links and
reference_audiosare only checked for being public HTTPS links before the task is created. An element video must run 3 to 8 seconds. - Have a local file? Upload it with
POST /v1/filesand pass the returneddata.url.
Prompt mentions
Each kind of input has its own mention, numbered from 1 in list order:
- A numbered or frame mention with nothing behind it is refused when the task is created, for example
the prompt names @last_frame, which this request does not send.
Combination rules
These are checked when the task is created; a request that breaks one is refused with 400 bad_request and costs nothing.
Fields this model does not accept
Sending one of these is refused before anything is charged, instead of being ignored:
sound,generate_audio,seed,multi_shots,multi_prompt,quality,watermark,task_type,output_format→field "sound" is not supported by model kling-v4(with the field you sent).- Any other unknown field →
unknown field: <name>.
Request examples
Text to video
A 5-second 16:9 clip at 720p with generated audio.
First and last frame
The video moves from the first image to the second at 1080p and takes the shape of the first frame.
Reference images and a voice
Two reference images and one voice, each named in the prompt.
Reference video with its own sound
Replace the placeholder with a 2–30 second clip of your own; keep_original_sound keeps its sound instead of generated audio.
Named elements
A character and a prop, each defined from two pictures (the first is the main view). Replace the placeholder links with pictures of your own.
Responses
Create a task (201)
The task object. output is null until the task succeeds. Fields marked “while running” disappear once the task finishes.
Finished task
GET /v1/tasks/{task_id} returns HTTP 200 with status: "succeeded" and the result in data.output.
Output fields
Failed task
A failed task is still HTTP 200 on GET /v1/tasks/{task_id}: the failure is in the body. The reservation is returned in full, so nothing is charged.
Complete example
Create a task, wait for it with the server’s polling hint, and print the result URLs. Set BEATAPI_API_KEY in your environment and install requests.
Billing
- The price is per second of video at the resolution you choose: 0.30 per second at
1080p. The list below shows 8-second clips. - The number of seconds is
duration, or 5 when you leave it out.usage.billable_duration_secondson the task shows it. - Every video comes with audio, generated or kept from the reference videos, at no separate charge.
- The price is reserved when the task is created and settled when the video is ready. A failed task, including one refused by moderation after submission, is refunded in full.
Current list prices, the same as on Pricing. An account with a negotiated discount pays less; data.usage on the task always shows the amount actually charged.
Common errors
HTTP errors at a glance
Errors before a task exists arrive as a non-2xx response, and nothing is charged. Branch on error.code or error.retryable; message names the problem. The full list and retry policy are on Errors.
Authentication
Send your API key as Authorization: Bearer <BEATAPI_API_KEY>.
Headers
Send the body as JSON with Content-Type: application/json. Idempotency-Key is optional: send a unique value (at most 255 characters) per logical request and reuse it only to retry that exact body. Within 24 hours a retry with the same key and body returns the first response again with Idempotent-Replayed: true; the same key with a different body returns 409 idempotency_conflict. Responses other than 2xx are not stored, so a retry after a 400 or 402 runs again.
Request
The model to run.
Value: kling-v4
If the value is wrong
- Missing:
"model" is required - An image model sent to this endpoint:
"model" nano-banana-2 is served by POST /v1/images/tasks, not this endpoint
What happens in the video: subject, action, camera movement, style and sound, with each input named by its @ mention.
Length: 1–5000 characters
- Length is counted in characters (a CJK character counts as one).
- Mentions:
reference_imagesare@image_1,@image_2…,reference_videosare@video_1…,reference_audiosare@voice_1…, and an element is@followed by itsname. Frames are@first_frame,@keyframe_1,@keyframe_2… and@last_frame. - Every
@must name an input of the same request. A numbered or frame mention with nothing behind it, such as@image_3with two reference images or@last_framewith one image, is refused when the task is created.
If the value is wrong
- Missing:
"prompt" is required - Empty or longer than the limit:
"prompt" has an unsupported length - A mention of an input the request does not send:
the prompt names @image_3, which this request does not send
Shape of the video as width:height.
Allowed values: 16:9, 9:16, 1:1, 21:9
Default: 16:9
- If you leave it out,
16:9is used. - Do not send it with
images: the video takes the shape of the first frame.
If the value is wrong
- A value not in the list:
"aspect_ratio" must be one of: [16:9 9:16 1:1 21:9] - Sent with
images:Kling V4 takes the first frame's shape; do not send aspect_ratio with images
Length of the video in seconds, a whole number. It is what you are billed for.
Default: 5
Range: 3–30
- If you leave it out,
5is used and billed. - With frames it also caps the number of images: at most
duration+ 1, and never more than 10.
If the value is wrong
- Outside the range, not a whole number, or sent as a string:
"duration" is outside its supported range
Up to seven named subjects, such as a character, an animal, a prop, a costume, a scene or an effect, each defined once and named in the prompt as @ followed by its name.
Items: ≤ 7
- An array of at most seven objects. Each object accepts these keys and no others:
elements[].name(string, required): 1 to 20 letters, digits, underscores or Chinese characters, unique within the request ignoring case. It cannot beimage_N,video_N,voice_N,keyframe_N,object_N,audio_N,first_frameorlast_frame.elements[].element_input_urls(array of strings): 2 to 4 public HTTPS links to pictures of the element; the first is its main view.elements[].element_input_video_urls(array of strings): exactly one public HTTPS link to a 3 to 8 second single-shot video of a character. Send this orelement_input_urls, not both.elements[].element_input_audio_urls(array of strings, optional): exactly one public HTTPS audio link, the voice of a character element.elements[].tag(string, optional): what the element is. A video element, or an element with a voice, must be a character: leavetagout or sendcharacter.elements[].description(string, optional): what the element is, at most 100 characters.- Video elements are at most 3, and at most 5 together with
reference_videos. Every element counts toward the limit of 15 reference inputs and elements. - Elements cannot be sent with
images.
If the value is wrong
- More than seven elements:
"elements" accepts at most 7 items - An element that is not an object:
"elements[0]" must be an object - An element without
name:"name" is required in "elements[0]" - A
namethat is empty or longer than 20:"elements[0].name" has an unsupported length - A
namewith other characters, or a reserved name:elements[0].name "image_1" is not a name Kling V4 accepts - The same
nametwice, ignoring case:elements[1].name "Hero" is used twice - Both pictures and a video, or neither:
elements[0] takes either element_input_urls or element_input_video_urls - Fewer than two pictures:
"elements[0].element_input_urls" requires at least 2 item - More than four pictures:
"elements[0].element_input_urls" accepts at most 4 items - A video element whose
tagis notcharacter:elements[0] is a video element, which is always a character - A voice on an element whose
tagis notcharacter:elements[0] has a voice, which only a character element takes - A
tagnot in the list:"elements[0].tag" must be one of: [character animal prop costume scene effect others] - A
descriptionlonger than 100 characters:"elements[0].description" has an unsupported length - A key that an element does not accept:
field "start_time" is not supported in "elements[0]" - More than three video elements:
Kling V4 takes at most 3 video elements - Combined with
images:Kling V4 cannot combine elements with images
Frames in time order: one link is the first frame, two are the first and last frame, and more add middle frames between them.
Items: 1–10
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- With three or more links,
images[0]is the first frame and the last link the last frame; the links in between are middle frames, soimages[1]is@keyframe_1,images[2]is@keyframe_2, and so on. - A video takes at most one image more than its seconds (
duration+ 1, counting 5 seconds whendurationis left out), and never more than 10. - Frames cannot be sent with
reference_images,reference_videos,reference_audios,elementsoraspect_ratio: the video takes the shape of the first frame.
If the value is wrong
- More than 10 links:
"images" accepts at most 10 items - More links than
duration+ 1 (here 7 links for a 5-second video):Kling V4 takes at most 6 images for a 5-second video - Combined with any reference_* field:
Cannot combine "images" with reference inputs in one task - Combined with
elements:Kling V4 cannot combine elements with images - Combined with
aspect_ratio:Kling V4 takes the first frame's shape; do not send aspect_ratio with images - Not an https:// link:
"images[0]" must be a public HTTPS URL
Keeps the reference videos’ own sound in the finished video instead of generated audio.
- Only valid with
reference_videos; sending it without them, even asfalse, is refused. - Without it the video comes with generated audio. There is no field that turns audio off.
If the value is wrong
- Not true or false:
"keep_original_sound" must be a boolean - Sent without
reference_videos:"keep_original_sound" needs reference_videos
Voices for the video. Name them in the prompt as @voice_1, @voice_2 … in list order.
Items: 1–3
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Cannot be combined with
images. - Count toward the limit of 15 reference inputs and elements together.
If the value is wrong
- More than the maximum:
"reference_audios" accepts at most 3 items
Pictures that guide the content, characters, products or style of the video. Name them in the prompt as @image_1, @image_2 … in list order.
Items: 1–10
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Cannot be combined with
images. - Count toward the limit of 15 reference inputs and elements together.
If the value is wrong
- More than the maximum:
"reference_images" accepts at most 10 items - More than 15 reference inputs and elements together:
Kling V4 takes at most 15 reference inputs and elements together
Videos to take motion, camera work or content from. Name them in the prompt as @video_1, @video_2 … in list order.
Items: 1–5
Each item is a public https:// URL. For a local file, upload it first with POST /v1/files and pass the returned data.url.
- Each clip runs 2 to 30 seconds, and all clips together at most 30 seconds. The gateway measures each clip before creating the task and refuses one outside these limits, naming it.
- Reference videos and video elements together are at most 5, and count toward the limit of 15 reference inputs and elements.
- The finished video has generated audio unless you send
keep_original_sound: true, which keeps the reference videos’ own sound.
If the value is wrong
- More than the maximum:
"reference_videos" accepts at most 5 items - A clip shorter than 2 or longer than 30 seconds:
reference_videos[0] is 35 seconds long; this model takes reference video of 2 to 30 seconds. - Clips that run longer than 30 seconds together:
The reference videos run 36 seconds in total; this model takes at most 30. - More than 5 reference videos and video elements together:
Kling V4 takes at most 5 reference videos and video elements together
Output resolution. 1080p costs more per second than 720p.
Allowed values: 720p, 1080p
Default: 720p
- If you leave it out,
720pis used and billed. - 4K is not available on this model.
If the value is wrong
- A value not in the list (for example
4Korpro):"resolution" must be one of: [720p 1080p]
Response
The task object. output is null until the task succeeds. Fields marked “while running” disappear once the task finishes.

