> ## Documentation Index
> Fetch the complete documentation index at: https://docs.argil.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> An image in one call, a video with a webhook, and a character in a scene.

## 1. Get an API key

Create a key in [**Workspace settings → API keys**](https://www.argil.ai/workspace-settings?tab=api-keys) of the Argil app and export it:

```bash theme={null}
export ARGIL_API_KEY="<your API key>"
```

Generating needs an active Argil plan, and spends the same credits as the playground.

## 2. Generate an image

`Prefer: wait=60` holds the response until the generation is final (up to 60 seconds), so most images come back finished in one call.

```bash cURL theme={null}
curl https://api.argil.ai/v2/generations \
  -H "Authorization: Bearer $ARGIL_API_KEY" \
  -H "Prefer: wait=60" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2.1",
    "mode": "text-to-image",
    "input": {
      "prompt": "Studio photo of a ceramic mug with steam, soft morning light",
      "aspect_ratio": "4:5"
    }
  }'
```

```python Python theme={null}
import os, requests

resp = requests.post(
    "https://api.argil.ai/v2/generations",
    headers={
        "Authorization": f"Bearer {os.environ['ARGIL_API_KEY']}",
        "Prefer": "wait=60",
    },
    json={
        "model": "nano-banana-2.1",
        "mode": "text-to-image",
        "input": {"prompt": "Studio photo of a ceramic mug with steam, soft morning light", "aspect_ratio": "4:5"},
    },
)
generation = resp.json()
print(generation["status"], generation["outputs"][0]["asset"]["url"])
```

```ts TypeScript theme={null}
const res = await fetch("https://api.argil.ai/v2/generations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ARGIL_API_KEY}`,
    Prefer: "wait=60",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "nano-banana-2.1",
    mode: "text-to-image",
    input: { prompt: "Studio photo of a ceramic mug with steam, soft morning light", aspect_ratio: "4:5" },
  }),
});
const generation = await res.json();
console.log(generation.status, generation.outputs[0].asset.url);
```

```json Response (trimmed) theme={null}
{
  "id": "gen_0a8d3e5f7c1b4e2a9d6c8f0b3e5a7c91",
  "object": "generation",
  "model": "nano-banana-2.1",
  "mode": "text-to-image",
  "status": "succeeded",
  "outputs": [
    {
      "type": "image",
      "asset": {
        "id": "asset_3f7a1c9e5b2d4a8e6c0f2b4d6a8e0c13",
        "url": "https://argildotai.s3-accelerate.amazonaws.com/external-assets/7b8d74e9/mug.png",
        "width": 896,
        "height": 1120
      }
    }
  ],
  "cost": { "currency": "credit", "estimated": 1.94, "reserved": 2, "charged": 2, "refunded": 0 }
}
```

The image is also in your library, in its `API` folder.

## 3. Animate it, get a webhook when done

Videos take one to ten minutes, so let Argil call you. Register your endpoint once; the response holds its signing secret, shown only this time:

```bash theme={null}
curl https://api.argil.ai/v2/webhook_endpoints \
  -H "Authorization: Bearer $ARGIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://hooks.example.com/argil", "enabled_events": ["generation.succeeded", "generation.failed"] }'
```

Then create the generation and keep its id. The output of step 2 is the first frame: no download, no upload.

```bash theme={null}
curl https://api.argil.ai/v2/generations \
  -H "Authorization: Bearer $ARGIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2.5",
    "mode": "image-to-video",
    "input": {
      "prompt": "Steam rises, slow push-in, morning light",
      "first_frame": "asset_3f7a1c9e5b2d4a8e6c0f2b4d6a8e0c13",
      "duration": 6,
      "resolution": "720p"
    },
    "metadata": { "order_id": "A-1042" }
  }'
```

The response comes back at once with `"status": "queued"` and a `Retry-After` header. When the video is done, your endpoint receives a signed `generation.succeeded` event with the full generation (see [Webhooks](https://docs.argil.ai/v2/platform/webhooks.md)). [Verify the signature](https://docs.argil.ai/v2/platform/webhooks.md#verify-signatures) before trusting it.

> [!TIP]
>
> No public endpoint yet? Poll with `GET /v2/generations/{id}` and `Prefer: wait=60`: about ten calls for a ten-minute video.

## 4. Put your character in a scene

List the characters made in Argil, then reference one by id and name it in the prompt:

```bash theme={null}
curl "https://api.argil.ai/v2/elements?kind=character" \
  -H "Authorization: Bearer $ARGIL_API_KEY"
```

```json theme={null}
{
  "model": "seedance-2.5",
  "mode": "reference-to-video",
  "input": {
    "prompt": "@image1 walks into the kitchen from @image2 and says hello, handheld camera",
    "references": [
      { "type": "element", "id": "elm_8e3b5d7f9a1c4e6b8d0f2a4c6e8b0d25", "plate": "front" },
      "asset_91a3c7e5b2d84f6a8e0c1b9d7f3a5e24"
    ],
    "duration": 8,
    "aspect_ratio": "9:16"
  }
}
```

`"plate": "front"` brings one image of the character (`@image1`), so the kitchen photo is `@image2`. Without it, the element brings all its plates, each counted as an image. The same tags work on every model: see [Inputs](https://docs.argil.ai/v2/generate/inputs.md#prompt-tags).

## 5. Check the price first

Send `model`, `mode` and `input` to `POST /v2/generations/estimate` to get the price and whether your balance covers it, without creating a generation:

```json theme={null}
{
  "object": "generation_estimate",
  "model": "seedance-2.5",
  "mode": "reference-to-video",
  "credits": { "estimated": 89.47, "reserved": 90 },
  "settlement": "settled_on_actual_usage",
  "balance": { "available": 1240.5, "sufficient": true }
}
```

## Next

> [card] [Models](https://docs.argil.ai/v2/models/overview.md)
>
> Every model, its modes, inputs and price.

> [card] [Generations](https://docs.argil.ai/v2/generate/generations.md)
>
> Lifecycle, waiting, outputs, failures.

> [card] [Library](https://docs.argil.ai/v2/library/assets.md)
>
> Uploads, outputs and Argil elements.

> [card] [Webhooks](https://docs.argil.ai/v2/platform/webhooks.md)
>
> Endpoints, signatures, retries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.