APIKO
Video Series

Kling 4.0 API

  • One model for text-to-video and video from references: send only prompt, or add reference images and reference videos. Reference audio is not accepted.
  • Videos of 3 to 30 seconds at 720p or 1080p. There is no 480p or 4K option.
  • Every video comes with a synchronized two-channel soundtrack, including lip-synced dialogue; there is no switch to turn sound off. Put the lines and sounds you want in the prompt.
  • First and last frames, video editing and video extension are not offered through this API.
  • Asynchronous: POST /v1/videos returns a task id; poll GET /v1/videos/{id} or GET /v1/tasks/{id} until the task completes, then download /v1/videos/{id}/content.
  • Result links are APIKO-signed and kept for 24 hours; download anything you need to keep.
  • Billing
    • Charged per second at the price of the chosen resolution; requests with reference videos have their own per-second price. Prices are on the model page.
    • Without reference videos (text only, or reference images only), billed seconds = output duration.
    • With reference videos, billed seconds = output duration + the larger of the reference videos' total length and the output duration, at the reference-video price. For example 5 s of output with 3 s of reference video bills 10 s; with 8 s of reference video, 13 s.
    • Reference images are not billed.
    • With reference videos, the amount held when the task is accepted is output + 30 seconds (the reference-video limit of this model); the difference is refunded when the task settles.
    • A task that fails is refunded in full.
POST
/
v1
/
videos
TASK_ID=$(curl https://api.apiko.app/v1/videos \
  -H "Authorization: Bearer $APIKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "kling-4.0",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "prompt": "A street vendor at a night market looks up and says in a warm voice: \"Fresh noodles, hot and ready.\" Steam rises, neon signs reflect on wet pavement, handheld camera, one continuous shot."
}' | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')

while :; do
  TASK=$(curl -s https://api.apiko.app/v1/videos/$TASK_ID \
    -H "Authorization: Bearer $APIKO_API_KEY")
  printf '%s\n' "$TASK"
  printf '%s' "$TASK" | grep -qE '"status": *"(completed|failed)"|"error": *\{' && break
  sleep 5
done
{
  "id": "task_abc123",
  "object": "video",
  "model": "kling-4.0",
  "status": "completed",
  "progress": 100,
  "video_url": "https://api.apiko.app/v1/tasks/task_abc123/artifacts/video/content?access=…"
}

Authorizations

Authorization
stringrequired
All requests use Bearer authentication: Authorization: Bearer <API_KEY>.
Create a key in Console → API Keys.
Routes
string
  • POST /v1/videos — create a video task
  • GET /v1/videos/{id} — query the task and read video_url
  • GET /v1/tasks/{id} — query the same task in the shared task format

Body

application/json
model
stringdefault:kling-4.0required
Use this exact public model id.
Available options: kling-4.0
Example:"kling-4.0"
prompt
stringrequired
Video description; dialogue, sound and camera directions go here too.
  • Up to 8,000 characters. Dialogue, sound and camera directions go in the prompt too; Chinese, English and other languages work, and dialect and multilingual speech can be requested in words.
  • Describe references in words (for example "the character in the first reference image"); there is no special placeholder syntax.
Minimum length: 1
Maximum length: 8000
Example:"A paper boat drifting across a calm lake at sunrise"
aspect_ratio
enum<string>default:adaptive
Adaptive lets the model choose (follows the reference image when there is one).
adaptive (default) lets the model choose and follows the reference image when there is one; or set 16:9, 9:16, 1:1 or 21:9.
Available options: adaptive, 16:9, 9:16, 1:1, 21:9
Example:"adaptive"
resolution
enum<string>default:720p
Output resolution of the video. Values are matched case-insensitively.
  • 720p is the default and the lowest price, 1080p the sharpest. There is no 480p or 4K.
  • Each resolution has its own per-second price; see the model page.
Available options: 720p, 1080p
Example:"720p"
duration
integerdefault:5
Output length in seconds; OpenAI's seconds field is accepted instead.
  • Length of the output video in seconds: any integer from 3 to 30; 5 when omitted.
  • seconds (a string such as "10", as in the OpenAI video API) is accepted as an alias; send one of the two.
Range: 3 ≤ x ≤ 30
Example:5
reference_image_urls
string<uri>[]
Reference image HTTPS URLs (characters, products, scenes), JPG or PNG, at least 300 px per side, aspect ratio between 1:2.5 and 2.5:1, up to 30 MB each.
  • Up to 10 JPG or PNG images, 30 MB each, at least 300 px per side, aspect ratio between 1:2.5 and 2.5:1: characters, products or scenes.
  • Public HTTPS URLs only; files and base64 are not accepted.
Items: 1–10
Example:["https://example.com/reference.png"]
reference_videos
string<uri>[]
Reference video HTTPS URLs for motion, camera or editing, 3-30 s in total, 700-4553 px per side, 24-60 fps, up to 300 MB each. A task with a reference video is billed at the reference-video rate for output + max(total reference length, output) seconds; submission holds output + 30 s and refunds the difference on completion.
  • Up to 5 clips, 3–30 seconds each and in total, 700–4553 px per side (at most 8,294,400 pixels), 24–60 fps and 300 MB each, for motion, camera work or editing rhythm.
  • Billed at the reference-video price on output + max(their total length, output) seconds.
  • Public HTTPS URLs only; files and base64 are not accepted.
Items: 1–5
Example:["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 header X-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, failed
progress
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.