const API = "https://kymaapi.com/v1";
const headers = {
Authorization: "Bearer ky-your-api-key",
"Content-Type": "application/json",
};
const submit = await fetch(`${API}/videos/generations`, {
method: "POST",
headers,
body: JSON.stringify({
model: "kling-3-pro",
prompt: "A drone shot over a misty mountain range at sunrise",
duration: 5,
}),
}).then((r) => r.json());
let job;
do {
await new Promise((r) => setTimeout(r, 3000));
job = await fetch(`${API}/jobs/${submit.id}`, { headers }).then((r) => r.json());
} while (!["succeeded", "failed", "expired", "refunded"].includes(job.status));
console.log(job.output.url);