Generate short video clips from text prompts.
The video generation endpoint produces short clips from a text prompt. Rendering is computationally intensive, so it runs asynchronously — you submit a job, then poll a job id for the result. The OpenAI SDK has no video resource, so call the endpoint directly with fetch.
const res = await fetch("https://opendunes.com/v1/videos", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OPENDUNES_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "example-provider/video-model",
prompt: "A camel caravan crossing the Grand Erg Occidental at sunset, cinematic, slow pan",
duration: 6,
}),
});
// Responds 202 with a poll URL
const { id, status } = await res.json();
console.log(id, status); // status: "pending"let job;
do {
await new Promise((r) => setTimeout(r, 5000)); // poll every 5 seconds
const poll = await fetch(`https://opendunes.com/v1/videos/${id}`, {
headers: { Authorization: `Bearer ${process.env.OPENDUNES_API_KEY}` },
});
job = await poll.json();
} while (job.status === "pending" || job.status === "in_progress");
if (job.status === "completed") {
console.log(job.unsigned_urls[0]); // download with the same Authorization header
}| Status | Meaning |
|---|---|
pending | Waiting for a generation slot |
in_progress | Actively generating |
completed | Output ready; the download link is in unsigned_urls, the clip's id in file_ids |
failed | Generation failed; error carries the reason |
| Field | Description |
|---|---|
model | Video generation model slug, from GET /v1/videos/models. |
prompt | Text description of the desired video. |
duration | Seconds of video. The lengths a model takes are its supported_durations. |
Nothing is charged at submission: the wallet moves once, when the job completes. A failed or timed-out job charges nothing. The download link does not expire, the clip is kept until you delete it, and downloading is free. See the video API reference.