KovAPIKovAPI
POST https://kovapi.com/v1/videos/generations

Kling 4.0 Flash is the Flash edition of Kling 4.0, at a lower price. Submit an async job with POST /v1/videos/generations: no references for text-to-video, or up to 10 reference images and 5 reference videos (20 s in all), to copy a video's motion or edit the video itself. 720P only, 3-20 seconds, 16:9 / 9:16 / 1:1 / 21:9, always with sound, no first / last frame. Billed per second; with reference videos by Kling's own formula.

Try in Playground →

Quick start

Three steps: submit a job, poll it, take the video link. Replace YOUR_API_KEY with your key and the commands below run as they are.

Step 1 · Submit (returns a job id at once, HTTP 202)

curl
curl https://kovapi.com/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kling-4.0-flash", "prompt": "a dancer spins through falling maple leaves while the camera circles her slowly", "duration": 5, "resolution": "720P", "size": "16:9"}'

Response (HTTP 202)

JSON
{
  "id": "img_5c2e8f1a9b3d7e6f0a4c8b2d",
  "object": "video.generation.job",
  "status": "queued",
  "created": 1791281400,
  "model": "kling-4.0-flash"
}

Step 2 · Poll every 5–10 seconds until status is succeeded or failed

curl
curl https://kovapi.com/v1/videos/jobs/img_5c2e8f1a9b3d7e6f0a4c8b2d \
  -H "Authorization: Bearer YOUR_API_KEY"

Response when it succeeds

JSON
{
  "id": "img_5c2e8f1a9b3d7e6f0a4c8b2d",
  "object": "video.generation.job",
  "status": "succeeded",
  "created": 1791281400,
  "model": "kling-4.0-flash",
  "data": [
    {"url": "https://img.kovapi.com/i/8c1f0e5d2b7a49e3a6d0c4f1b9e2a7d5.mp4"}
  ],
  "usage": {"clips": 1, "model": "kling-4.0-flash"}
}

Step 3 · data[0].url is the clip (MP4). It is kept for 7 days; download it to your own storage to keep it longer.

Complete example (Python: submit, wait, save to disk)

Python
import time
import requests

BASE = "https://kovapi.com/v1"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

# 1. submit
job = requests.post(f"{BASE}/videos/generations", headers=HEADERS, json={
    "model": "kling-4.0-flash",
    "prompt": "a dancer spins through falling maple leaves while the camera circles her slowly",
    "duration": 5,
    "resolution": "720P",
    "size": "16:9",
}).json()
if "error" in job:
    raise SystemExit(job["error"]["message"])

# 2. poll every 10 seconds, for up to an hour
deadline = time.time() + 3600
while job["status"] not in ("succeeded", "failed") and time.time() < deadline:
    time.sleep(10)
    job = requests.get(f"{BASE}/videos/jobs/{job['id']}", headers=HEADERS).json()

# 3. download the video
if job["status"] == "succeeded":
    url = job["data"][0]["url"]
    with open("kling-4.0-flash.mp4", "wb") as f:
        f.write(requests.get(url).content)
    print("saved", url)
elif job["status"] == "failed":
    print("failed:", job["error"]["code"], job["error"]["message"])
else:
    print("still", job["status"], job["id"])

While queued, the poll also returns queue_position (jobs ahead of yours) and eta_seconds (expected wait). If your time limit passes, do not resubmit: the job is still there, so keep polling the same id later.

Authentication

Header
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Create an API Key in the console to start.

At a glance

Duration3–20 s in one-second steps (default 5 s)
Resolution720P
Aspect ratio16:9 / 9:16 / 1:1 / 21:9
Reference imagesup to 10 · all used as references (characters, outfits, props, settings); Flash has no first / last frame
Reference videosup to 5 · each 3-30 s and 700-4553 px high, 20 s in all · copy the motion, or edit the video itself
Reference audionot accepted (write dialogue, effects and music in the prompt)
Soundalways on, cannot be switched off (audio: false is refused)
Prompt lengthKling's own limit: up to 26,000 English characters or 11,000 other characters, mixed text counted in proportion; over 5,000 characters the clip must be 5-20 s
Billingper second: output seconds x the rate; with reference videos: the rate x 2/3 x max(output seconds x 2, output seconds + reference-video seconds)

Request parameters

The JSON body of POST /v1/videos/generations:

ParameterTypeRequiredDescription
modelstringYesThe model id: kling-4.0-flash.
promptstringYesWhat happens, the camera, the action and the sound, within the Kling length limit (see the spec table). With references, say what each one is for, e.g. "following the moves in the reference video, the character in image 1 swings the spear in the forest of image 2"; to edit the video itself, say what changes and what stays, e.g. "turn the corgi into a voxel corgi, keep its moves, the camera and the original sound".
durationintegerNoOutput length, an integer 3–20, default 5; alias seconds.
resolutionstringNo720P only (default).
sizestringNo16:9 (default), 9:16, 1:1 or 21:9; alias aspect_ratio. Other ratios are refused (400). With a first frame the clip takes its shape.
imagesarrayNoUp to 10 reference images (public links, data: URIs or base64, each up to 16 MB); also image (one) or reference_images. All are references: Flash has no first / last frame (image_role=first_frame is refused).
video_referencesarrayNoUp to 5 reference videos (mp4 / mov, each 3-30 s, 700-4553 px high and up to 50 MB, 20 s in all): direct download links, base64 (data:video/mp4;base64,...) or links from a Playground upload. Billed by Kling's own formula, see Pricing below.
audiobooleanNoEvery clip has sound and it cannot be switched off; false is refused (400), so leave it out.
callback_urlstringNoWhere to push the result when the job ends; see Webhooks below.
nintegerNoEach job makes one clip; leave it out. A value above 1 still makes one clip, but n clips are held at submit and the extra is returned when the job ends.

Other fields (seed, negative_prompt, fps, watermark and the like) are not passed on and do not change the price; results are always MP4, returned as a url.

Price

Billed per second: without reference videos, cost = the rate of the resolution x output seconds; with reference videos, Kling's own formula: the rate x 2/3 x max(output seconds x 2, output seconds + the seconds of every reference video), the same link counted once. Reference images are free. The amount is held at submit, charged on success and refunded in full on failure. 1 credit = $0.005.

ResolutionCredits / sUSD / sA 5-second clip5 s output + a 10 s reference video (15 s x 2/3)
720P12$0.06$0.30$0.60

Reference material

  • Reference images: all references, never a first frame. Say in the prompt what each one is for by its number, e.g. "the character in image 1", "the setting in image 2".
  • Reference videos: copy their motion and camera, or edit the video itself (a new subject, style or background); they combine with reference images. Each 3-30 s and 700-4553 px high (e.g. 1280x720 landscape or 720x1280 portrait), 20 s in all. We download and measure each one at submit: one whose length cannot be read, too short or not high enough is refused with a 400 and nothing is charged.
  • First / last frame: not on Flash; use Kling 4.0 for that. No reference audio: write dialogue, effects and music in the prompt.
  • Each image is a public image URL, a data: URI or base64, up to 16 MB; send several as an array in images. We store the images before the job is queued; one that cannot be read is refused with 400, message says which, and nothing is charged.
  • Reference files we store and the results are both kept for 7 days.

With reference images and a reference video

curl
curl https://kovapi.com/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kling-4.0-flash", "prompt": "following the moves in the reference video, the character in image 1 swings the spear in the forest of image 2 as the camera follows", "images": ["https://example.com/character.png", "https://example.com/forest.png"], "video_references": ["https://example.com/moves-1280x720.mp4"], "duration": 10, "resolution": "720P", "size": "16:9"}'

This job outputs 10 s with a 5 s reference video: max(20, 15) = 20 s x the rate x 2/3.

Job status and fields

GET /v1/videos/jobs/{id} reports these statuses; every field is described in Async jobs. Poll every 5–10 seconds, or let a webhook (below) push the result. Polling is free, and any key of the same account can read the job.

StatusMeaning
queuedWaiting in line. Carries queue_position (jobs ahead of yours) and eta_seconds (expected wait).
processingRendering.
succeededDone. The result is in data[0].url, the billing detail in usage.
failedFailed. The reason is in error; the credits held for the job are refunded in full.
  • processing can go back to queued, for example while the service is busy, while a finished clip is fetched again, or after a restart. If a job cannot be finished, the gateway may render it again automatically; however many retries it takes, a job is charged once.
  • One account runs up to 50 jobs at a time; further jobs wait in submission order, and a job that has not started after 15 minutes fails and is refunded in full. Job records are kept for 3 days and video links for 7 days.

How long it takes

Usually 5-10 minutes, longer when the queue is busy; we wait up to 120 minutes and refund in full after that.

Median render time in our tests: 9.1 min.

Errors and refunds

An error at submit comes back at once as HTTP 4xx / 5xx: no job is created and nothing is charged. A failure after the job was accepted is reported by the job endpoint, and the hold is refunded in full. Every code is listed under Error codes.

Errors at submit

HTTPcodeCauseWhat to do
400invalid_requestA parameter is not valid: the duration, resolution, ratio or number of references is outside this model's range, the prompt is too long, a reference image or video cannot be read, audio: false was sent to a model whose clips always have sound, and so on. message says which.Fix what message says and submit again.
400invalid_callback_urlcallback_url is not a public http(s) address, or is longer than 2000 characters.Use an address that can be reached from the internet.
400model_not_foundThe model id is misspelled, model is missing, or the model cannot be used on this endpoint (a chat model on the image endpoint, for example).Use a model id from GET /v1/models or the API reference.
401invalid_api_keyThe key does not exist, was deleted or is disabled, or the account is disabled.Check the key on the API Keys page of the console.
402insufficient_quotaNot enough balance to hold this request. The gateway holds the highest possible cost of the request first, so a burst of concurrent calls can trigger it too.After a burst, wait a few seconds and retry; otherwise top up.
429rate_limit_exceededOver the requests-per-minute limit set on this key (counted over the last 60 seconds). No Retry-After header.Wait a few seconds and retry, or raise the key's limit in the console.
503model_maintenanceThe model is under maintenance and takes no requests; no other model answers in its place meanwhile.Retry when maintenance ends; see Status.
503service_unavailableA temporary failure on our side, such as storing a reference file. No job was created and nothing was charged.Retry shortly.

Failed jobs (status failed)

codeWhen you see itWhat to do
content_policyVideo: the prompt, a reference, or the generated picture or sound did not pass content review (param is audio when the sound was flagged). Wan Standard and Prime: input material did not pass review. error.reason is FaceDetectionSuspect (possible real human face) or DataInspectionFailed (input content review failed). error.message explains the cause and recommended change. Failed tasks are not billed.Rewrite the prompt or replace the reference before you submit again; the same input is refused again.
duration_rejectedA reference video was not accepted: its length is outside the rule (each 3-30 s, 20 s in all).Trim the reference videos to 3-30 s (20 s in all) and submit again; the same request fails again.
render_failedVideo: no clip came out this time, usually a one-off.Submitting the same request again usually works.
render_timeoutVideo: queueing or rendering took too long and the upstream gave the job up.Submit again.
result_fetch_failedThe video was rendered, but downloading or storing it kept failing on our side.Submit again.
upstream_errorAny other failure: the automatic retries did not help, the job waited 15 minutes without starting, the upstream refused without a reason, and so on; message says which.Submitting again usually works.

Branch on code, not on the text of message. Treat any code you do not recognise (or a missing one) as upstream_error: resubmitting usually works. Every failed job is refunded in full.

Webhooks instead of polling

Add callback_url when you submit and the moment the job ends, success or failure, the gateway pushes exactly what the poll endpoint returns to that URL, signed and retried on failure. You can also set an account-wide address under Settings → Webhook in the console. Webhook docs →

curl · callback_url
curl https://kovapi.com/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kling-4.0-flash", "prompt": "a dancer spins through falling maple leaves while the camera circles her slowly", "duration": 5, "resolution": "720P", "size": "16:9", "callback_url": "https://your-domain.com/webhook"}'