# Quickstart

> Create an API key and make your first video with the HalationLab.ai API in under five minutes.

You need a HalationLab.ai account with tokens in it and a terminal with `curl`.

## 1. Create an API key

1. In the HalationLab.ai app, open **Account → Developers** and create a key.
2. Choose the projects it can use (all by default) and its spending limit (on by default, resets monthly).
3. Copy the key. It starts with `hl_live_` and is shown only once.

Put it in an environment variable for the commands below:

```sh
export HALATIONLAB_API_KEY="hl_live_..."
```

> **Keep the key on your server:** An API key spends tokens from your account. Never put it in a web page, a mobile app or a public repository. Apps that run in a browser use [OAuth](https://docs.halationlab.ai/apps/oauth.md) instead.

## 2. Generate a video

```sh
# Generates a 5-second video and waits up to 60 seconds for it. Spends at most 400 tokens.
set -euo pipefail
API="${HL_API_BASE:-https://api.halationlab.ai/v1}"

curl -sS --fail-with-body "$API/generations" \
  -H "Authorization: Bearer $HALATIONLAB_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=60" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2.5",
    "input": { "prompt": "A red fox running through snow", "duration": 5, "aspect_ratio": "16:9" },
    "max_cost": 400
  }'
```

What this request does:

- `model` and `input` say what to make. `input` follows the model's parameters; see [Seedance 2.5](https://docs.halationlab.ai/models/seedance-2.5.md).
- `max_cost` is the most you will pay, in tokens. If the quoted price is higher, nothing is created or charged and the answer is [`402 max_cost_exceeded`](https://docs.halationlab.ai/errors/max-cost-exceeded.md) with the quote.
- `Idempotency-Key` makes a retry safe: sending the same request again with the same key never starts a second video. See [Idempotency](https://docs.halationlab.ai/guides/idempotency.md).
- `Prefer: wait=60` holds the response for up to 60 seconds until the video is ready.

The answer is a generation (`201`). When it has finished, `status` is `completed` and `outputs[0].url` is the video:

```json
{
  "id": "gen_01JD3Y5RJ6M3XW6J8K2N4P7Q9T",
  "object": "generation",
  "status": "completed",
  "model": "seedance-2.5",
  "cost": { "quoted_max": 380, "charged": 372, "final": true },
  "outputs": [
    { "asset": "asset_01JD3Y7M2K8P4W6R0T3V5X9Z1B", "type": "video", "url": "https://app.halationlab.ai/media/d/…", "url_expires_at": "2026-11-28T11:41:12Z" }
  ],
  "poll_after_seconds": null
}
```

If the video is not ready within 60 seconds, `status` is still `queued` or `processing`: read the generation again with `GET /v1/generations/{id}` (it accepts `Prefer: wait=60` too), waiting `poll_after_seconds` between reads. See [Waiting and polling](https://docs.halationlab.ai/guides/waiting-and-polling.md).

The download URL needs no credentials and expires after an hour; read the generation again for a fresh one.

## 3. The same with an SDK

TypeScript (`npm install @halationlab/sdk`):

```ts
// Generates a 5-second video with the TypeScript SDK and prints its download URL. Spends at most 400 tokens.
import { HalationLab } from '@halationlab/sdk';

const hl = new HalationLab({ apiKey: process.env.HALATIONLAB_API_KEY });

// run() starts the generation and waits until it is completed, failed or canceled.
const generation = await hl.generations.run({
  model: 'seedance-2.5',
  input: { prompt: 'A red fox running through snow', duration: 5, aspect_ratio: '16:9' },
  max_cost: 400,
});

console.log(generation.status, generation.cost.charged, generation.outputs[0]?.url);
```

Python (`pip install halationlab`):

```python
# Generates a 5-second video with the Python SDK and prints its download URL. Spends at most 400 tokens.
import os

from halationlab import HalationLab

client = HalationLab(api_key=os.environ["HALATIONLAB_API_KEY"])

# run() starts the generation and waits until it is completed, failed or canceled.
generation = client.generations.run(
    model="seedance-2.5",
    input={"prompt": "A red fox running through snow", "duration": 5, "aspect_ratio": "16:9"},
    max_cost=400,
)

print(generation["status"], generation["cost"]["charged"], generation["outputs"][0]["url"] if generation["outputs"] else None)
```

`run()` starts the generation and waits for a final status, so you do not write the polling loop yourself.

## Next

- [Authentication](https://docs.halationlab.ai/authentication.md): what a key can do and how long it lasts.
- [Generating video and images](https://docs.halationlab.ai/guides/generating.md): images, image to video from a URL, and your own files.
- [Webhooks](https://docs.halationlab.ai/guides/webhooks.md): be told when work finishes instead of waiting.
- [Go-live checklist](https://docs.halationlab.ai/go-live.md) before you ship.

Source: https://docs.halationlab.ai/quickstart/
