# Get the result

`GET /v1/generations/{id}` returns the generation. Add `?wait=60` and the call waits for up to 60 seconds, answering as soon as `status` is `succeeded` or `failed`; call it again in a loop until it is. That one call is all you need to check a job: no other status endpoint, no sleep between calls. It is free and never counts against a rate limit.

```bash cURL
ID=gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c

curl -s "https://vidlab.ai/v1/generations/$ID?wait=60" \
  -H "Authorization: Bearer $VIDLAB_API_KEY"
```

```python Python
import os, requests

job_id = "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c"
r = requests.get(
    f"https://vidlab.ai/v1/generations/{job_id}",
    params={"wait": 60},
    headers={"Authorization": f"Bearer {os.environ['VIDLAB_API_KEY']}"},
    timeout=90,
)
job = r.json()["data"]
print(job["status"], [o["url"] for o in job["outputs"]])
```

```js JavaScript
const jobId = "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c";
const res = await fetch(`https://vidlab.ai/v1/generations/${jobId}?wait=60`, {
  headers: { Authorization: `Bearer ${process.env.VIDLAB_API_KEY}` },
});
const { data: job } = await res.json();
console.log(job.status, job.outputs.map((o) => o.url));
```

A finished generation:

```json
{
  "data": {
    "id": "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c",
    "object": "generation",
    "status": "succeeded",
    "model": "seedance-2.5",
    "variant": "720p",
    "units": 5,
    "price_usd": 1.05,
    "outputs": [{ "url": "https://...", "mime": "video/mp4" }],
    "created_at": "2026-11-01T18:04:11.000Z",
    "finished_at": "2026-11-01T18:06:02.000Z"
  }
}
```

- `wait` is whole seconds, 0 to 60 (more is read as 60); left out, the call answers at once. At the deadline the answer is `200` with the job as it stands (`queued` or `running`) and a `Retry-After` header: call again.
- Can your app receive a POST from the web? Send `webhook_url` (https) with the generation: we POST `{"event": "generation.succeeded" | "generation.failed", "generation": {"id": "gen_...", "object": "generation", "status": "succeeded"}}` to it when the job ends, with an `x-vidlab-event` header, and try up to 3 more times if your server does not answer `2xx`. It carries the id and the status only, no files and no links: read `GET /v1/generations/{id}` with your key for the outputs. A webhook is a nudge, not a signed message, so always read the job before you act on it.
- When it says `succeeded`, download the files right away (below): the links in `outputs[].url` last 6 hours.
- Never start a second generation while the first is still `queued` or `running`: wait on the one you have. A second one is a second charge.
- `GET /v1/jobs/{id}`, `/v1/jobs/{id}/status` and `/v1/jobs/{id}/result` are older names for the same answer (and take `wait` too); use `GET /v1/generations/{id}`.
- Another account's id answers `404 generation_not_found`.

## Download the file

The files are in `outputs`. Download them with your key, so you never depend on a link that expires: `GET /v1/generations/{id}/content` is the first file, `/content/2` the second, and so on. The answer redirects to the stored file, so follow redirects (`curl -L`; `fetch` and `requests` do by default).

```bash cURL
curl -sL https://vidlab.ai/v1/generations/$ID/content \
  -H "Authorization: Bearer $VIDLAB_API_KEY" -o out.mp4
```

```python Python
import os, requests

job_id = "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c"
file = requests.get(
    f"https://vidlab.ai/v1/generations/{job_id}/content",
    headers={"Authorization": f"Bearer {os.environ['VIDLAB_API_KEY']}"},
)
open("out.mp4", "wb").write(file.content)
```

```js JavaScript
import { writeFile } from "node:fs/promises";

const jobId = "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c";
const file = await fetch(`https://vidlab.ai/v1/generations/${jobId}/content`, {
  headers: { Authorization: `Bearer ${process.env.VIDLAB_API_KEY}` },
});
await writeFile("out.mp4", Buffer.from(await file.arrayBuffer()));
```

- A generation that is not finished answers `409 not_ready` (with `Retry-After`), a failed one `409 generation_failed`, and a number past the last file `404 output_not_found`.
- The `url` in `outputs` is a signed link that lasts 6 hours; each poll returns a working one. The files themselves are kept for 30 days after the generation finished (`outputs_kept_until`). Copy files you want to keep longer to your own storage.
- An image call with `n` above 1 returns one output per image.

## List generations

`GET /v1/generations` returns your generations, newest first, with the same key. It is free and never rate limited. Use it for a task log, or to find an id you lost.

| Query | Values | What it does |
| - | - | - |
| `limit` | 1 to 100 (default 25) | How many generations in the page. |
| `starting_after` | A generation id | The next page: send the last id of the page before. |
| `status` | `queued`, `running`, `succeeded`, `failed` | Only generations in that status. |
| `model` | A model id | Only that model's generations. |

```bash cURL
curl -s "https://vidlab.ai/v1/generations?limit=10&status=succeeded" \
  -H "Authorization: Bearer $VIDLAB_API_KEY"
```

The answer is `{ "object": "list", "data": [generation, ...], "has_more": false }`. When `has_more` is `true`, call again with `starting_after` set to the last `id`. A bad query value answers `400` (`invalid_limit`, `invalid_status`, `invalid_model`, `invalid_starting_after`).
