# Quickstart

One key, one request shape, every image, video and audio model. This page makes your first generation in three steps: submit it, wait for it, download the file.

Before you start, [create your account](/docs/setup). You need an API key in `VIDLAB_API_KEY` and some credit.

## 1. Submit a generation

Every model runs on the same endpoint, `POST /v1/generations`. Send the model's id and its inputs. This example asks `seedance-2.5` for a 5 second vertical video.

```bash cURL
curl -s -X POST https://vidlab.ai/v1/generations \
  -H "Authorization: Bearer $VIDLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "seedance-2.5",
    "input": {
      "prompt": "A slow push-in on a perfume bottle on wet black stone",
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "9:16"
    }
  }'
```

```python Python
import os, uuid, requests

API = "https://vidlab.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['VIDLAB_API_KEY']}"}

r = requests.post(
    f"{API}/generations",
    headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())},
    json={
        "model": "seedance-2.5",
        "input": {
            "prompt": "A slow push-in on a perfume bottle on wet black stone",
            "resolution": "720p",
            "duration": 5,
            "aspect_ratio": "9:16",
        },
    },
)
r.raise_for_status()
job = r.json()["data"]
print(job["id"], job["status"])
```

```js JavaScript
const API = "https://vidlab.ai/v1";
const headers = { Authorization: `Bearer ${process.env.VIDLAB_API_KEY}` };

const res = await fetch(`${API}/generations`, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({
    model: "seedance-2.5",
    input: {
      prompt: "A slow push-in on a perfume bottle on wet black stone",
      resolution: "720p",
      duration: 5,
      aspect_ratio: "9:16",
    },
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
let { data: job } = await res.json();
console.log(job.id, job.status);
```

The call answers `202` at once. The work runs in the background, so the answer is the queued generation: its `id`, and its price in `price_usd`, held from your balance while it runs. The sample below is shortened: every field is on [The generation object](/docs/generation-object). Keep the `id`.

```json
{
  "data": {
    "id": "gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c",
    "object": "generation",
    "status": "queued",
    "model": "seedance-2.5",
    "variant": "720p",
    "units": 5,
    "outputs": [],
    "status_url": "/v1/generations/gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c"
  }
}
```

The `Idempotency-Key` makes a retry safe: the same key returns the same generation and never charges twice. Every field of the request is on [Submit a generation](/docs/submit-a-generation).

## 2. Wait for it

Ask for the generation with `?wait=60`. The call stays open for up to 60 seconds and answers as soon as the job ends. Call it in a loop until `status` is `succeeded` or `failed`. It is free and never counts against a rate limit.

```bash cURL
ID=gen_4Fq9xT2mLr7Kd1sV8bN3pZ0c

while true; do
  STATUS=$(curl -s "https://vidlab.ai/v1/generations/$ID?wait=60" \
    -H "Authorization: Bearer $VIDLAB_API_KEY" | jq -r .data.status)
  echo "$STATUS"
  case "$STATUS" in succeeded|failed) break ;; esac
done
```

```python Python
while job["status"] in ("queued", "running"):
    job = requests.get(
        f"{API}/generations/{job['id']}",
        params={"wait": 60},
        headers=HEADERS,
        timeout=90,
    ).json()["data"]
print(job["status"])
```

```js JavaScript
while (job.status === "queued" || job.status === "running") {
  job = (await (await fetch(`${API}/generations/${job.id}?wait=60`, { headers })).json()).data;
}
console.log(job.status);
```

Can your server receive a POST from the web? Send `webhook_url` with the generation and we call you when it ends. See [Get the result](/docs/get-the-result).

## 3. Download the file

When the status is `succeeded`, download the file with your key. The answer redirects to the stored file, so follow redirects.

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

```python Python
if job["status"] == "succeeded":
    file = requests.get(f"{API}/generations/{job['id']}/content", headers=HEADERS)
    open("out.mp4", "wb").write(file.content)
else:
    print(job["error"]["code"], job["error"]["message"])
```

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

if (job.status === "succeeded") {
  const file = await fetch(`${API}/generations/${job.id}/content`, { headers });
  await writeFile("out.mp4", Buffer.from(await file.arrayBuffer()));
} else console.error(job.error.code, job.error.message);
```

Downloading costs nothing. The generation was charged once, when it succeeded; a failed one is free, and its `error` says why: see [Why a generation failed](/docs/why-a-generation-failed).

## Text models

A text model answers in the same call: nothing to poll, nothing to download. `POST /v1/chat/completions` takes the OpenAI chat shape, with the same key and balance.

```bash cURL
curl https://vidlab.ai/v1/chat/completions \
  -H "Authorization: Bearer $VIDLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5.5",
    "max_tokens": 2000,
    "messages": [{"role": "user", "content": "Write one headline for a red running shoe."}]
  }'
```

Streaming, tools, images and what a call costs: [Text models](/docs/text-models).

## Where to go next

- [Models](/models): every model with its inputs, limits, prices and request code.
- [Price it first](/docs/price-it-first): a free quote for the exact request, and `max_cost_usd` to cap it.
- [Uploads](/docs/uploads): send a picture, a clip or a sound from your machine.
- [Go-live checklist](/docs/go-live): what to check before you send real traffic.

## Endpoints at a glance

| | |
| - | - |
| Base URL | `https://vidlab.ai/v1` |
| Auth | `Authorization: Bearer $VIDLAB_API_KEY`. Make a key on [API keys](/api-keys). |
| Submit | `POST /v1/generations` |
| Text | `POST /v1/chat/completions`, answered in the call |
| Poll | `GET /v1/generations/{id}?wait=60`: one call, in a loop (or send `webhook_url`) |
| Download | `GET /v1/generations/{id}/content` |
| Price | `POST /v1/generations/quote` (free, nothing held) |
| Models | `GET /v1/models` (no key) |
| Balance | `GET /v1/balance` |
| Upload | `POST /v1/uploads` |
| Format | JSON in, JSON out. Prices are US dollars; the dashboard shows credits, 100 credits = $1. |
| Machine-readable | [`/v1/openapi.json`](https://vidlab.ai/v1/openapi.json), [`/llms.txt`](https://vidlab.ai/llms.txt), [`/llms-full.txt`](https://vidlab.ai/llms-full.txt), [`/SKILL.md`](https://vidlab.ai/SKILL.md) |

Every page of these docs is also Markdown: add `.md` to its URL, for example [https://vidlab.ai/docs/quickstart.md](https://vidlab.ai/docs/quickstart.md).
