Skip to Content
DocumentationModelsVideoKling 4.0

Kling 4.0

Use kling-4.0 to create video output. This page contains the complete request needed for this model.

Model facts

PropertyValue
Model IDkling-4.0
EndpointPOST /api/v1/generation/create
OutputVideo
Modestext-to-video, image-to-video, video reference
PricingView current pricing 

Minimal request

curl -X POST https://api.api-stock.com/api/v1/generation/create \ -H "Authorization: Bearer $API_STOCK_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light" } }'

The create response contains a task ID:

{ "code": 200, "data": { "taskId": "019ca881-9503-7270-a560-f00fc2b15785", "status": "not_started", "createdAt": "2026-08-22T12:00:00.000Z" } }

Parameters

Parameters belong inside the top-level input object. Unknown fields are rejected.

ParameterTypeRequiredDefaultDescription
promptstringNo—Describe the scene. Use @Image1 / @Element1 for references. Required unless multiShots is supplied; mutually exclusive with multiShots.
videoMode“elements” | “start_end_frame” | “transform” | “video_reference”No—Omit for pure text-to-video. Use elements for references, start_end_frame for keyframes, transform or video_reference for a source video.
resolution“720p” | “1080p”No"720p"Output resolution (4K is not available)
durationnumberNo3Output seconds, 3–30. Ignored with source video (its probed duration is billed) or multiShots (shot durations are summed). min 3, max 30
aspectRatio“auto” | “16:9” | “9:16” | “1:1” | “21:9”No—Aspect ratio; must be auto with a source video. Keyframes determine their own ratio.
generateAudiobooleanNotrueGenerate native stereo audio (included in the price)
keepAudiobooleanNotruePreserve source video audio
imageUrlsstring[]No—Raw references (up to 10); address as @Image1, @Image2. Requires elements, transform or video_reference mode.
startImageIndexnumberNo—1-based imageUrls index anchoring the first frame (elements mode) min 1, max 10
elementsobject[]No—Subject elements: { description?: string, type?: image | video, imageUrls?: string[1..4], videoUrl?: string }. Up to 7, at most 3 video elements. Images and elements together: at most 15, or 14 with source video.
startFrameUrlstringNo—Required first frame in start_end_frame mode
keyframeUrlsstring[]No—Ordered middle frames (up to 8) in start_end_frame mode; at most 10 total frames
endFrameUrlstringNo—Optional last frame in start_end_frame mode
videoUrlstringNo—Source video for transform / video_reference. Duration is probed before charging; 3–30 seconds. Transform needs a short side of at least 700px.
multiShotsobject[]No—2–6 scenes totalling 3–30 seconds; replaces prompt and duration. Only text-to-video and elements modes.

Modes

Minimal generation

{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light" } }

Image references

{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light", "videoMode": "elements", "imageUrls": [ "https://example.com/input.jpg" ], "startImageIndex": 1 } }

Keyframes

{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light", "videoMode": "start_end_frame", "startFrameUrl": "https://example.com/start.jpg", "keyframeUrls": [ "https://example.com/middle.jpg" ], "endFrameUrl": "https://example.com/end.jpg", "duration": 15 } }

Source video transform

{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light", "videoMode": "transform", "videoUrl": "https://example.com/source.mp4", "aspectRatio": "auto" } }

Subject elements

{ "model": "kling-4.0", "input": { "prompt": "A cinematic scene with soft natural light", "videoMode": "elements", "elements": [ { "type": "image", "description": "A red toy car", "imageUrls": [ "https://example.com/car.jpg" ] } ] } }

Multiple scenes

{ "model": "kling-4.0", "input": { "multiShots": [ { "prompt": "Wide shot of a coastal city", "duration": 10 }, { "prompt": "Close-up of a boat", "duration": 5 } ] } }

Constraints

  • videoMode: allowed: elements, start_end_frame, transform, video_reference.
  • resolution: allowed: 720p, 1080p.
  • duration: minimum 3; maximum 30.
  • aspectRatio: allowed: auto, 16:9, 9:16, 1:1, 21:9.
  • startImageIndex: minimum 1; maximum 10.
  • Text-only requests omit videoMode and all media inputs. Without a source video, text-to-video requests conditioned on raw images (imageUrls) or subject/object references (elements) require elements mode. With a source video, imageUrls and elements are also accepted in transform and video_reference modes. Keyframes require start_end_frame and startFrameUrl, with at most 10 total frames. Keyframes reject elements, raw image references, source video and multiShots.
  • Each element has optional description (100 characters), type (image by default, or video), and either imageUrls (1–4 URLs) or videoUrl. Raw images and elements share a cap of 15, or 14 with source video. At most 3 video elements are supported.
  • multiShots replaces prompt, has 2–6 scenes and must total 3–30 seconds. Billing uses this total rather than duration. Only text-to-video and elements modes support multiShots.
  • transform and video_reference require videoUrl and aspectRatio auto. The source duration is probed before charging, rounded up to whole seconds and billed at the with-video rate; requested duration is ignored. Source videos must be 3–30 seconds; transform requires a short side of at least 700px.
  • Audio is included in the rate. 4K, HDR, Flash, voice references and video extension are not available. Initial client prices use the actual provider launch discount plus 50%, rounded up to the standard client increment; consult current pricing.

Invalid types, unsupported enum values, out-of-range numbers, and missing required fields return HTTP 400 with error.code: "invalid_input". Correct the request rather than retrying it unchanged.

Result

Poll the task or provide a top-level webhook URL in the create request:

curl https://api.api-stock.com/api/v1/task/status/$TASK_ID \ -H "Authorization: Bearer $API_STOCK_KEY"

A successful media task returns one or more files:

{ "code": 200, "data": { "taskId": "019ca881-9503-7270-a560-f00fc2b15785", "status": "finished", "files": [ { "fileUrl": "https://s3.api-stock.com/result.mp4", "fileType": "video" } ], "createdTime": "2026-08-22T12:00:00.000Z" } }

See Tasks and webhooks for terminal statuses, retries and webhook delivery.

Kling 4.0 — API Stock