import requests, time headers = {"Authorization": "Bearer " + AIMLAPI_KEY} job = requests.post( "https://api.aimlapi.com/v2/video/generations", headers=headers, json={ "model": "kling-video/v2.6/pro/image-to-video", "prompt": "A serene timelapse of clouds over a mountain range" }, ).json() gid = job["id"] while True: res = requests.get(f"https://api.aimlapi.com/v2/video/generations?generation_id={gid}", headers=headers).json() if res.get("status") in ("completed", "error"): break time.sleep(5) print(res["video"]["url"])
const headers = { Authorization: `Bearer ${process.env.AIMLAPI_KEY}`, "Content-Type": "application/json", }; const job = await (await fetch("https://api.aimlapi.com/v2/video/generations", { method: "POST", headers, body: JSON.stringify({ "model": "kling-video/v2.6/pro/image-to-video", "prompt": "A serene timelapse of clouds over a mountain range" }), })).json(); let res; do { await new Promise((r) => setTimeout(r, 5000)); res = await (await fetch(`https://api.aimlapi.com/v2/video/generations?generation_id=${job.id}`, { headers })).json(); } while (!["completed", "error"].includes(res.status)); console.log(res.video.url);
# submit the generation — the response contains the job "id" curl -X POST https://api.aimlapi.com/v2/video/generations \ -H "Authorization: Bearer $AIMLAPI_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"kling-video/v2.6/pro/image-to-video","prompt":"A serene timelapse of clouds over a mountain range"}' # then poll until status is "completed" — video.url holds the result curl "https://api.aimlapi.com/v2/video/generations?generation_id={id}" -H "Authorization: Bearer $AIMLAPI_KEY"
OpenAI-compatible — swap the base URL and it works with your existing SDK.
| Type | Price |
|---|---|
| Input | |
| Output |