Video Series
Kling 4.0 Flash API
- Generate 3–20 second videos at 720p from text, a first frame, reference images or reference videos.
- Use
first_image_urlfor a start frame, or usereference_image_urlsandreference_videosfor references. - Send
POST /v1/videosto create the task. PollGET /v1/videos/{id}until complete, then download the signed video. - With reference videos, add up their durations and round the total up to a whole second. Billed seconds are the output duration plus the greater of that rounded total and the output duration. Prices are on the model page.
POST
Authorizations
All requests use Bearer authentication:
Authorization: Bearer <API_KEY>.Create a key in Console → API Keys.
Routes
string
POST /v1/videos— create a video taskGET /v1/videos/{id}— query the task and readvideo_urlGET /v1/tasks/{id}— query the same task in the shared task format
Body
application/json
model
stringdefault:kling-4.0-flashrequired
Use this exact public model id.
Available options:
kling-4.0-flashExample:
"kling-4.0-flash"prompt
stringrequired
Video description. Include desired dialogue and sounds in the prompt.
Minimum length:
1Maximum length:
8000Example:
"A paper boat drifting across a calm lake at sunrise"aspect_ratio
enum<string>default:adaptive
The first frame determines the aspect ratio when first_image_url is supplied.
Available options:
adaptive, 16:9, 9:16, 1:1, 21:9Example:
"adaptive"resolution
enum<string>default:720p
Output resolution of the video. Values are matched case-insensitively.
Available options:
720pExample:
"720p"duration
integerdefault:5
Output length in seconds. OpenAI's seconds field is accepted instead.
Length of the video in seconds.
Range:
3 ≤ x ≤ 20Example:
5first_image_url
string<uri>
Single public HTTPS first-frame image URL. May not be combined with reference images or videos.
- The first frame sets the output aspect ratio. Send it by itself, without reference images or videos.
- Public HTTPS URLs only; files and base64 are not accepted.
Example:
"https://example.com/first-frame.png"reference_image_urls
string<uri>[]
Public HTTPS reference image URLs. Each image must be at least 300 pixels per side and have an aspect ratio between 2:5 and 5:2.
Public HTTPS URLs only; files and base64 are not accepted.
Items:
1–10Example:
["https://example.com/reference.png"]reference_videos
string<uri>[]
Public HTTPS reference videos, 3 seconds or longer per clip and 20 seconds at most in total. Billed for output duration plus the greater of output duration or total input duration. Submission holds output duration plus 20 seconds.
- Each clip must be at least 3 seconds. The combined duration can be at most 20 seconds. Submission holds output duration plus 20 seconds; at settlement, the combined reference duration is rounded up to a whole second.
- Public HTTPS URLs only; files and base64 are not accepted.
Items:
1–5Example:
["https://example.com/reference.mp4"]callback_url
string<uri>
Optional public HTTPS URL notified when the task finishes.
- When the task finishes, APIKO POSTs the same JSON as
GET /v1/tasks/{id}with headerX-Apiko-Task-Id, retrying up to 3 times. - Callbacks are not signed: re-fetch the task to confirm the result.
Example:
"https://your-domain.com/webhooks/apiko-task"Response
200 - application/json
Charged when the request is accepted; a task that ends in failed is refunded in full.
id
string
Video task id. Query it with
GET /v1/videos/{id} or GET /v1/tasks/{id}.Example:
"task_abc123"status
enum<string>
Task status. Poll every 5–10 seconds until it is
completed or failed.Available options:
queued, in_progress, completed, failedprogress
integer
Progress from
0 to 100.video_url
string<uri>
Present on
GET /v1/videos/{id} when the task is completed: an APIKO-signed link kept for 24 hours. GET /v1/tasks/{id} returns the same link as data[0].url.Errors
application/json
Errors use the shape { "error": { "message", "type", "param", "code" } }; most messages end with a request id to quote when you contact support.
400
error
Invalid request. Fix the request instead of retrying it; it is not charged.
- A field this page does not list, e.g.
seed is not supported. - A value outside the listed options or range, e.g.
duration must be an integer from …. - A missing or empty
prompt(prompt is required). - A reference URL that is not public HTTPS (
… must be a public HTTPS URL).
401
error
Missing or invalid API key (
Invalid token).403
error
Insufficient balance (
code: "insufficient_user_quota"). Add credit in Console → Billing.404
error
GET /v1/videos/{id} or GET /v1/tasks/{id} for a task that does not exist or belongs to another account (Task not found).503
error
The model exists but none of its routes can take the request right now:
No available channel for model … (code: "model_not_found"). Retry later with backoff, or pick another model. A missing or misspelled model returns 404 with the same message; check the id instead of retrying.