# Video jobs

Generate video as a job, with live progress.

Video takes from seconds to minutes, so it runs as a job. `POST /v1/videos/generations` returns `202` with a job; then follow it in one of three ways:

- `GET /v1/jobs/{id}/events`: Server-Sent Events with live `progress` and `eta_seconds`.
- `GET /v1/jobs/{id}`: poll every few seconds.
- `"webhook_url"` in the request: we POST the finished job to it. Deliveries are not signed or retried yet, so also poll or follow the events as a backup.

`eta_seconds` is `null` when a job runs longer than usual. Finished videos are on `cdn.ewest.ai` for 7 days.

For image-to-video, send `image_url` (and `end_image_url` on models that take a last frame) as a public `https://` address. Uploads and data URIs are not accepted, and some models take only JPEG and PNG. [Files](https://ewest.ai/docs/files#urls) explains how to make an address work and which errors you can get.

cURL:

```bash
# 1. Create the job
curl https://api.ewest.ai/v1/videos/generations \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ewest/veo-3.1-fast", "prompt": "A red fox walks through fresh snow"}'
# → 202 {"id": "job_…", "status": "queued", "progress": 0, "eta_seconds": …}

# 2. Follow live progress (Server-Sent Events), or poll GET /v1/jobs/job_…
curl -N https://api.ewest.ai/v1/jobs/job_…/events -H "Authorization: Bearer $EWEST_KEY"
```

Python:

```python
import os, time, requests

H = {"Authorization": f"Bearer {os.environ['EWEST_KEY']}"}
job = requests.post("https://api.ewest.ai/v1/videos/generations", headers=H,
                    json={"model": "ewest/veo-3.1-fast", "prompt": "A red fox walks through fresh snow"}).json()
while job["status"] not in ("succeeded", "failed"):
    time.sleep(3)
    job = requests.get(f"https://api.ewest.ai/v1/jobs/{job['id']}", headers=H).json()
    print(job["status"], job["progress"], job["eta_seconds"])
print(job["output"]["url"] if job["output"] else job["error"])
```

JavaScript:

```javascript
const H = { Authorization: `Bearer ${process.env.EWEST_KEY}`, "Content-Type": "application/json" };
let job = await (await fetch("https://api.ewest.ai/v1/videos/generations", {
  method: "POST", headers: H,
  body: JSON.stringify({ model: "ewest/veo-3.1-fast", prompt: "A red fox walks through fresh snow" }),
})).json();
while (!["succeeded", "failed"].includes(job.status)) {
  await new Promise((r) => setTimeout(r, 3000));
  job = await (await fetch(`https://api.ewest.ai/v1/jobs/${job.id}`, { headers: H })).json();
}
console.log(job.output?.url ?? job.error);
```

Source: https://ewest.ai/docs/video
