Kling
Kuaishou Kling video models — text-to-video and image-to-video with the async task pattern.
Kling video models use the async task pattern: submit → poll → download, same workflow as Seedance. Different models and capabilities use different create-task paths; see the corresponding model page for the complete field list.
Workflow
- Submit: send a prompt (text-to-video) or reference image + prompt (image-to-video), get a task ID
- Poll: query status by task ID until
succeeded - Download: fetch the video URL from the result (time-limited)
import time
import requests
BASE = "https://api.tokenhub.belivestudios.com"
HEADERS = {
"Authorization": "Bearer sk-your-key",
"Content-Type": "application/json",
}
# 1. Submit a Kling 3.0 text-to-video task
task = requests.post(
f"{BASE}/text-to-video/kling-3.0",
headers=HEADERS,
json={
"prompt": "An orange cat running across a keyboard, tracking shot",
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 3,
},
},
timeout=30,
).json()
if task.get("code") != 0:
raise RuntimeError(task)
task_id = task["data"]["id"]
# 2. Poll the common task endpoint
while True:
result = requests.get(
f"{BASE}/tasks",
params={"task_ids": task_id},
headers=HEADERS,
timeout=30,
).json()
if result.get("code") != 0:
raise RuntimeError(result)
item = result["data"][0]
if item["status"] == "succeeded":
video_url = item["outputs"][0]["url"]
break
if item["status"] == "failed":
raise RuntimeError(item)
time.sleep(5)
print(video_url)Note
The example uses the Kling 3.0 text-to-video endpoint. Kling 3.0 Turbo, 3.0 Omni, and O1 use different paths, input types, and fields; copy the example from the corresponding model page. After task creation, use the returned data.id with GET /tasks?task_ids=...; when the status is succeeded, read the video url from data[].outputs[]. Result URLs are time-limited, so save them promptly.