Bun script: submit a Wan 3.0 video job, poll it and save clip.mp4

A single Bun file that posts to /v1/videos for wan-3.0, polls until completed and writes clip.mp4 with Bun.write; the 5-second 480p test costs $0.3125.

5 min readSume
All posts

A Bun script needs no packages: fetch the POST /v1/videos endpoint with model: "wan-3.0", poll the polling_url until status leaves pending and in_progress, then write the response of GET /v1/videos/{id}/content?index=0 with Bun.write. The 5-second 480p test below costs $0.3125 on Sume (Video Router, read 2026-10-05).

What is the full script?

Run it with bun run clip.ts after exporting SUME_API_KEY. Bun supports top-level await and Bun.sleep.

const base = "https://api.sume.com/v1/videos";
const headers = {
  Authorization: `Bearer ${process.env.SUME_API_KEY}`,
  "Content-Type": "application/json",
};
const res = await fetch(base, {
  method: "POST",
  headers,
  body: JSON.stringify({
    model: "wan-3.0",
    prompt: "A kite rises over a grassy hill, wind in the grass",
    duration: 5,
    resolution: "480p",
    aspect_ratio: "16:9",
  }),
});
const job = await res.json();
let status = job.status;
while (status === "pending" || status === "in_progress") {
  await Bun.sleep(10_000);
  const poll = await (await fetch(job.polling_url, { headers })).json();
  status = poll.status;
  console.log(status);
}
if (status === "completed") {
  const video = await fetch(`${base}/${job.id}/content?index=0`, { headers });
  await Bun.write("clip.mp4", video);
}

Which Wan 3.0 options can I change?

Wan 3.0 accepts 2 to 30 seconds, 480p, 720p or 1080p, auto, adaptive, 16:9, 4:3, 1:1, 3:4 and 9:16 aspect ratios, and first_frame, last_frame and reference inputs. It does not take seed or size: those return 400 unsupported_parameter.

wan-3.0 request fields on Sume (read 2026-10-05)
FieldWan 3.0 value
duration2 to 30 whole seconds
resolution480p, 720p, 1080p
aspect_ratioauto, adaptive, 16:9, 4:3, 1:1, 3:4, 9:16
seednot accepted (400)
sizenot accepted (400)

How do I make it safe to re-run?

Add an Idempotency-Key header to the submit call so a re-run returns the original job. The same idea in other runtimes is covered in the Swift version, and the Wan prompt wording is in the Wan 3.0 prompt guide.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume