Generate Videos with Kling
What you can do
Use WorldRouter’s async video task routes to generate videos with Kuaishou Kling. Create a task on the route that matches your input, then poll its status until the video is ready, and download the output video from the task response.
Before you start
- You need a team-scoped API key with available credit. Kling bills by generated second and settles only after the task reaches a terminal status.
- Use the same base URL from Quickstart. Kling video lives under the
/v1/videossurface. - Kling request bodies use PascalCase fields, and the status route must match the route you created the task on.
Start from Quickstart if you still need an API key or the
base URL. Use the same origin shown there: https://inference-api-pre-d80ca3.worldrouter.ai.
Supported models
| Model | Create endpoint | Notes |
|---|---|---|
kling-v2-6 | /v1/videos/text2video, /v1/videos/image2video | Text- or image-to-video; Mode std/pro. |
kling-v3 | /v1/videos/text2video, /v1/videos/image2video | Text- or image-to-video; Mode std/pro. |
kling-v3-omni | /v1/videos/omni-video | Omni; optional first-frame image. |
Kling accepts a Duration of 5 or 10 seconds. Send it as a string
("5"); a numeric 5 is also accepted and coerced to a string before it
reaches the upstream.
Quick start flow
- 1Create a video task on the endpoint that matches your model and input.
- 2Save the task
idreturned by the create response. - 3Poll the matching status route until the job reaches a terminal state.
- 4When
statusbecomessucceeded, download the video fromcontent.video_url.
Create a task
Kling request bodies use PascalCase fields. Pick the endpoint that matches your input:
- Text-to-video —
POST /v1/videos/text2video(kling-v2-6,kling-v3). - Image-to-video —
POST /v1/videos/image2video(kling-v2-6,kling-v3) with anImageList. - Omni —
POST /v1/videos/omni-video(kling-v3-omni), optionally with a first-frame image.
curl -X POST "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/text2video" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"Model": "kling-v3",
"Prompt": "A cinematic shot of a city street at sunset.",
"Duration": "5",
"Mode": "std",
"AspectRatio": "16:9"
}'To guide generation with a first frame, send the request to
/v1/videos/image2video (or /v1/videos/omni-video for kling-v3-omni) with an
ImageList. Use the image2video route, not text2video — text2video
does not accept an ImageList and rejects the request. image2video derives the
ratio from the image, so omit AspectRatio:
curl -X POST "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/image2video" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"Model": "kling-v3",
"Prompt": "Animate this scene with a slow dolly-in.",
"Duration": "5",
"Mode": "std",
"ImageList": [
{ "ImageUrl": "https://your-host.example.com/first-frame.png", "Type": "first_frame" }
]
}'Image URLs must be publicly reachable so the upstream model can fetch them. An unreachable URL fails the task with a concise error once it is polled.
Typical create response:
{
"id": "job-123",
"model": "kling-v3",
"status": "queued",
"kling_action_family": "text",
"requestId": "req-123"
}Save the returned task id, then continue to Check task status.
Check task status
Poll until the task reaches a terminal state. The status route must match the route you created the task on:
- Text-to-video —
GET /v1/videos/text2video/{task_id} - Image-to-video —
GET /v1/videos/image2video/{task_id} - Omni —
GET /v1/videos/omni-video/{task_id}
curl "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/text2video/job-123" \
-H "Authorization: Bearer your_api_key"Typical status response:
{
"id": "job-123",
"model": "kling-v3",
"status": "succeeded",
"kling_action_family": "text",
"content": {
"video_url": "https://media.example.com/kling/output.mp4"
}
}WorldRouter normalizes upstream task states into:
queuedrunningsucceededfailedcancelledexpired
Download the output
Only download the result after the task status becomes succeeded:
curl -L "https://media.example.com/kling/output.mp4" -o output.mp4Read the final video URL from content.video_url in the task status response, not from the create response.
Notes and limits
- Billing is per generated second and settles when the task reaches a terminal state. Kling pricing varies by
Mode(std/pro). Token-count fields are intentionally empty for these models — only the Credit charge moves. - A task is rejected at create time if your team balance is too low.
- The number of in-flight, or pending, tasks per user is capped. Exceeding the cap returns
429. - Task reads are owner-scoped: you can only poll a task created by the same authorized account, team, or API key. Cross-owner reads return
403 media_resource_access_denied. - The status query must use the same capability route used to create the task.
- List routes are disabled. A
GETwithout a task id is not supported. - Input image URLs must be publicly reachable so the upstream model can fetch them.
Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
400 unsupported model | Wrong model for the endpoint | Use a Kling model on the Kling routes (text2video/image2video/omni-video). |
402 kling_balance_too_low | The scoped team does not have enough available credits | Recharge on Credits and retry. |
403 kling_team_required | The key is not scoped to a team | Use a team-scoped API key. |
403 media_resource_access_denied | The task belongs to another owner context | Poll with the same account, team, or API key that created the task. |
429 kling_too_many_pending_tasks | Too many of your Kling tasks are still running | Wait for active tasks to finish before creating more. |
424 with an error body | The upstream video provider returned an error or timed out | No task was created and nothing was billed. The body keeps the upstream error code and upstream_status. Retry after a short wait, or fix the reported parameter. |
| Task fails with a fetch/download error | An input image URL is unreachable | Use a publicly reachable https:// URL. |
See also
- Grok video guide: the Grok Imagine async video API.
- Seedance video guide: the Seedance async task API.
- Generate Images (OpenAI-compatible): image generation, including Grok Imagine image.
- API reference: chat completions for text models.
- Models: full catalog with live pricing.
- Quickstart: API key and base URL.