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.

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.
| Field | Wan 3.0 value |
|---|---|
| duration | 2 to 30 whole seconds |
| resolution | 480p, 720p, 1080p |
| aspect_ratio | auto, adaptive, 16:9, 4:3, 1:1, 3:4, 9:16 |
| seed | not accepted (400) |
| size | not 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
- Burn an 'AI-generated' disclosure line into a clip with caption cues
YouTube asks creators to disclose realistic AI content. Add an authored on-screen line with Sume caption cues, no speech-to-text, that travels with the file.
- Burn captions from TTS word timings: no second transcription
Ask Sume TTS for word timings, group them into phrases and send them as caption cues. The caption job skips speech-to-text and still costs $0.20.
- Callback or polling for Omni 4K jobs on the Sume video API
Use callback_url on /v1/videos or mode webhook on the Video Router for Omni 4K batches: one signed request per job, not repeated polls. Checks included.
- Can I put my Sume API key in the MCP server URL? No, use a header
Do not put a Sume key in the MCP URL. The MCP auth spec bans tokens in the query string. Send a Bearer or x-api-key header, or use OAuth, in each client.
Written by Sume