WorldRouter

Skip to Content

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/videos surface.
  • Kling request bodies use PascalCase fields, and the status route must match the route you created the task on.
Tip:

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

ModelCreate endpointNotes
kling-v2-6/v1/videos/text2video, /v1/videos/image2videoText- or image-to-video; Mode std/pro.
kling-v3/v1/videos/text2video, /v1/videos/image2videoText- or image-to-video; Mode std/pro.
kling-v3-omni/v1/videos/omni-videoOmni; 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

  1. 1Create a video task on the endpoint that matches your model and input.
  2. 2Save the task id returned by the create response.
  3. 3Poll the matching status route until the job reaches a terminal state.
  4. 4When status becomes succeeded, download the video from content.video_url.

Create a task

Kling request bodies use PascalCase fields. Pick the endpoint that matches your input:

  • Text-to-videoPOST /v1/videos/text2video (kling-v2-6, kling-v3).
  • Image-to-videoPOST /v1/videos/image2video (kling-v2-6, kling-v3) with an ImageList.
  • OmniPOST /v1/videos/omni-video (kling-v3-omni), optionally with a first-frame image.
curl
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 text2videotext2video does not accept an ImageList and rejects the request. image2video derives the ratio from the image, so omit AspectRatio:

curl
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" }
  ]
}'
Tip:

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:

200 OK
{
"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
curl "https://inference-api-pre-d80ca3.worldrouter.ai/v1/videos/text2video/job-123" \
-H "Authorization: Bearer your_api_key"

Typical status response:

200 OK
{
"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:

  • queued
  • running
  • succeeded
  • failed
  • cancelled
  • expired

Download the output

Only download the result after the task status becomes succeeded:

curl
curl -L "https://media.example.com/kling/output.mp4" -o output.mp4

Read 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 GET without a task id is not supported.
  • Input image URLs must be publicly reachable so the upstream model can fetch them.

Troubleshooting

SymptomLikely causeWhat to do
400 unsupported modelWrong model for the endpointUse a Kling model on the Kling routes (text2video/image2video/omni-video).
402 kling_balance_too_lowThe scoped team does not have enough available creditsRecharge on Credits and retry.
403 kling_team_requiredThe key is not scoped to a teamUse a team-scoped API key.
403 media_resource_access_deniedThe task belongs to another owner contextPoll with the same account, team, or API key that created the task.
429 kling_too_many_pending_tasksToo many of your Kling tasks are still runningWait for active tasks to finish before creating more.
424 with an error bodyThe upstream video provider returned an error or timed outNo 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 errorAn input image URL is unreachableUse a publicly reachable https:// URL.

See also

Last updated on