# Avatarity API reference for AI agents

> Avatarity makes Veo 3.1 Lite videos, Nano Banana images and talking-avatar videos over one REST API. Operated by Axtrelis LLC.

- Base URL: `https://avatarity.dev` (every path below starts with `/v1/`)
- Auth: `Authorization: Bearer $AVATARITY_API_KEY` on every call
- API key: read it from the environment variable `AVATARITY_API_KEY` (create one at https://avatarity.dev/studio/api-keys; it starts with `av_live_`). Never put it in browser code or a git repository.
- Format: JSON request and response bodies over HTTPS
- Retries: send `Idempotency-Key: <uuid>` on every POST that starts a render
- Human docs: https://avatarity.dev/docs · Errors: https://avatarity.dev/docs/errors · OpenAPI: https://avatarity.dev/v1/openapi.json

## Rules for agents

1. Keep the API key on the server. Read it from `AVATARITY_API_KEY`.
2. Video renders, async image requests and long avatar renders are asynchronous: create, then poll the task every 10 seconds (avatars: 15) or use a webhook. Never block a short serverless request on a render.
3. Final task states: `succeeded`, `failed`, `cancelled` (avatar tasks: `completed`, `failed`). Failed renders are not counted.
4. Retry only on `429` and `503`, after `Retry-After` or `X-RateLimit-Reset`, with the same `Idempotency-Key`.
5. Download result links soon: they are pre-signed and expire.

## All endpoints

- `GET /v1/models`: List the models on sale right now, with their options; no key needed.
- `POST /v1/video/generations`: Start a video render and get its task id back right away.
- `POST /v1/video/generations`: Turn one of your finished 720p videos into 1080p; counts as 1 video.
- `POST /v1/images/generations`: Make 1 to 4 images from a prompt and get their links in the same answer.
- `GET /v1/avatar/catalog`: List the avatars (with their looks) and the voices you can use right now.
- `POST /v1/avatar/generate`: Render a talking-avatar video from a script (or an audio file).
- `GET /v1/avatar/tasks/{id}`: Check an avatar render and get its video link when it is done.
- `GET /v1/avatar/custom`: List the avatars you made from your own photos, with their looks.
- `POST /v1/avatar/custom`: Turn a portrait photo into an avatar (a new look) you can render with.
- `GET /v1/tasks/{id}`: Check a video or image task and get its result links when it is done.
- `GET /v1/webhooks/secret`: See which webhook signing secret is active (masked).
- `POST /v1/webhooks/secret/rotate`: Create a new webhook signing secret; it is shown once.
- `GET /v1/usage`: See your plan, what is left this month and how many renders run right now.
- `GET /v1/tokens`: List the API keys on your account (never the full key).
- `POST /v1/tokens/{id}/rotate`: Get a new secret for a key while the old one keeps working for a grace period.
- `DELETE /v1/tokens/{id}`: Switch a key off for good.

## Getting started

Base URL, your API key, what each call counts against, and the rules for retries and limits.

### Base URL and API key

Every endpoint lives under `https://avatarity.dev/v1/`. Requests and answers are JSON over HTTPS.

Create a key in the Studio at https://avatarity.dev/studio/api-keys. It starts with `av_live_` and is shown once. Keep it on your server (for example in `AVATARITY_API_KEY`), never in browser code.

Send it on every call as `Authorization: Bearer $AVATARITY_API_KEY`.

Check your key:

```bash
curl -sS https://avatarity.dev/v1/usage \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

### Your first video

Start a render, poll the task until `status` is `succeeded`, then download `video_url`. The script below does all three with curl and jq.

first-video.sh:

```bash
# 1. Your key from https://avatarity.dev/studio/api-keys
export AVATARITY_API_KEY="av_live_..."

# 2. Start a render. The answer is 202 with a task_id.
TASK_ID=$(curl -sS -X POST https://avatarity.dev/v1/video/generations \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "model": "veo-3.1-lite",
  "prompt": "A slow dolly shot across a quiet harbour at sunrise, fishing boats rocking gently, mist on the water.",
  "aspect_ratio": "16:9"
}' | jq -r '.task_id')
echo "task: $TASK_ID"

# 3. Poll every 10 s until the task succeeds or fails.
while true; do
  TASK=$(curl -sS https://avatarity.dev/v1/tasks/$TASK_ID \
    -H "Authorization: Bearer $AVATARITY_API_KEY")
  STATUS=$(echo "$TASK" | jq -r '.status')
  echo "status: $STATUS ($(echo "$TASK" | jq -r '.progress_pct')%)"
  case "$STATUS" in
    succeeded) break ;;
    failed|cancelled) echo "$TASK" | jq '.error'; exit 1 ;;
  esac
  sleep 10
done

# 4. Download the MP4 (video_url is a pre-signed link; it expires, so fetch it soon).
curl -sS -L -o first-video.mp4 "$(echo "$TASK" | jq -r '.video_url')"
echo "saved first-video.mp4"
```

### What each call counts

Video and image calls count against your monthly plan. One 720p video counts as 1 video, one 1080p video counts as 2 videos (720p plus an upscale pass), and upscaling a finished video to 1080p counts as 1 video. Every image counts as 1 image, so `n: 4` counts 4.

A render that fails or is cancelled is never counted. Allowances reset each paid month and do not roll over. `GET /v1/usage` shows what is left.

Avatar videos are paid from avatar credits, not from the plan: Avatar 3 costs $0.25 per minute of finished video, billed by the second.

| Plan | Price | Videos / month | Images / month | Renders at once |
| --- | --- | --- | --- | --- |
| Free | $0 | Free renders | Free renders | 1 |
| Starter | $30 / month | 2,000 | 5,000 | 4 |
| Pro | $70 / month | 8,000 | 20,000 | 4 |
| Advanced | $250 / month | 25,000 | 50,000 | 8 |
| Dedicated | $400 / month | No fixed cap | No fixed cap | 16 |

### Rate limits and parallel renders

Each key has a limit of requests per minute. Answers carry `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (seconds until the window resets). Over the limit you get `429 RATE_LIMIT_EXCEEDED`: wait until the reset, then retry with backoff.

Your plan also sets how many renders run at once (table above). Over that you get `429 CONCURRENCY_LIMIT`: wait for a task to finish and retry.

Video and image answers carry `X-Avatarity-Remaining-Veo` and `X-Avatarity-Remaining-Images`: what is left this month.

### Safe retries (Idempotency-Key)

Send `Idempotency-Key: <uuid>` on every POST that starts a render. Retrying with the same key within 24 hours returns the first answer (header `X-Cache: Idempotent-Hit`) and never starts or counts a second render.

While the first request is still being accepted, the same key answers `409 IDEMPOTENT_OPERATION_IN_FLIGHT`: wait a second and retry with the same key. Use a new key for a new render.

### List models: `GET /v1/models`

List the models on sale right now, with their options; no key needed. No API key needed.

Example:

```bash
curl -sS https://avatarity.dev/v1/models
```

Response `200`:

```json
{
  "object": "list",
  "data": [
    {
      "id": "veo-3.1-lite",
      "object": "model",
      "type": "video",
      "product": "veo",
      "supported_parameters": [
        "prompt",
        "aspect_ratio",
        "duration",
        "resolution",
        "image",
        "seed",
        "webhook_url"
      ]
    },
    {
      "id": "nano-banana-pro",
      "object": "model",
      "type": "image",
      "product": "images"
    }
  ]
}
```

Shortened. Each model also lists its aspect ratios, resolutions and billing.

## Video

Veo 3.1 Lite video with sound from a text prompt, a start frame, start and end frames, or reference images. Renders run in the background: you get a task id at once.

### What you can send

Text only: `prompt`. Animate a picture: add `image` (the first frame). Go from one picture to another: add `image` and `end_frame`. Keep a person, product or style the same: add up to 3 `reference_images` with `reference_images_consent: true` (not together with frames).

Images can be public `https://` URLs or `data:image/...;base64,` URIs (PNG, JPEG or WebP, up to 15 MB).

Every clip is 4, 6 or 8 seconds (default 8), 16:9 or 9:16, at 720p (1 video) or 1080p (2 videos). Each length counts the same.

### Omni clips (longer, paid per clip)

Send `model: "omni-1.2-flash"` for a 720p clip with sound from a text prompt, 16:9 or 9:16. It is paid from your Omni credits (prepaid in the Studio under Billing), not from the plan, and only when the clip is delivered.

`duration` is 8 or 10 to 15 seconds (default 8). A length between two sold lengths is rounded to the nearer one; a length outside the range is refused with `VALIDATION_FAILED`. The `duration_seconds` in the response says which length you get.

The price depends on the length: GET /v1/models lists `durations_seconds` and `billing.prices_by_duration` (cents per clip) for `omni-1.2-flash`. A `dry_run` request answers `price_cents` for exactly that clip without starting it.

### Create a video: `POST /v1/video/generations`

Start a video render and get its task id back right away.

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `prompt` | string | yes | What happens in the clip: scene, camera, light, sound, dialogue. 3 to 10,000 characters, sent as written. |
| `model` | string | no | `veo-3.1-lite` (default), or `omni-1.2-flash` (Omni clips, text only, paid from Omni credits). |
| `duration` | integer | no | `4`, `6` or `8` seconds (default `8`). Omni: `8` or `10` to `15`; the price follows the length (GET /v1/models `prices_by_duration`). Alias `duration_seconds`. |
| `aspect_ratio` | string | no | `16:9` (default) or `9:16`. |
| `resolution` | string | no | `720p` (default, counts 1 video) or `1080p` (counts 2 videos). |
| `image` | string | no | First frame: `https://` URL or `data:image` URI. Alias `start_frame`. |
| `end_frame` | string | no | Last frame, same format. Use together with `image`. |
| `reference_images` | string[] | no | Up to 3 `https://` image URLs that keep a person, product or style consistent. Not together with `image` or `end_frame`. |
| `reference_images_consent` | boolean | no | Must be `true` with `reference_images`: you own the images or have permission from everyone shown. |
| `seed` | integer | no | Same seed and prompt give a similar result. |
| `webhook_url` | string | no | Public `https://` URL we POST to when the task starts, succeeds or fails. See Tasks & webhooks. |
| `dry_run` | boolean | no | `true`: check the request only. Answers `200` with `status: "validated"` (Omni: plus `price_cents` for that clip); nothing starts and nothing is counted. |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/video/generations \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "veo-3.1-lite",
    "prompt": "A slow dolly shot across a quiet harbour at sunrise, fishing boats rocking gently, mist on the water.",
    "aspect_ratio": "16:9",
    "duration": 8,
    "resolution": "720p"
  }'
```

Response `202`:

```json
{
  "id": "task_mhx2k9q1_4f7a9c2e81b3",
  "task_id": "task_mhx2k9q1_4f7a9c2e81b3",
  "status": "queued",
  "model": "veo-3.1-lite",
  "duration_seconds": 8,
  "eta_seconds": 90,
  "created_at": "2026-11-23T09:30:00.000Z",
  "links": {
    "query": "/v1/video/query?task_id=task_mhx2k9q1_4f7a9c2e81b3"
  }
}
```

Shortened. Then poll GET /v1/tasks/{id} or wait for your webhook.

Common errors:

- `400 INVALID_PAYLOAD`: The JSON body failed the schema check. error.details names each field and what is wrong with it. Fix the fields named in error.details. Do not retry the same body unchanged.
- `400 VALIDATION_FAILED`: A field has a value this model does not accept, for example a video aspect ratio other than 16:9 or 9:16, or an image URL that is not public HTTPS. Fix the field named in the message and retry.
- `400 CONTENT_POLICY_VIOLATION`: The prompt or an input image was refused by the content check. Image calls answer 422 when the model refuses after starting. Nothing is counted. Change the prompt or the image. Real people, minors, sexual content, violence, public figures and copyrighted characters are the usual reasons. Do not resend the same content.
- `402 ALLOWANCE_EXHAUSTED`: This month’s videos or images are used up. Upgrade the plan in Plan & billing, or wait for the next paid month. GET /v1/usage shows what is left.
- `429 CONCURRENCY_LIMIT`: The API already runs as many renders as your plan allows at once. Wait for one to finish (poll GET /v1/tasks/{id}) and retry.
- `429 RATE_LIMIT_EXCEEDED`: This key sent more requests per minute than it may. Wait until X-RateLimit-Reset (seconds) has passed, then retry with backoff.

### Upscale a video to 1080p: `POST /v1/video/generations`

Turn one of your finished 720p videos into 1080p; counts as 1 video.

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `source_task_id` | string | yes | The task id of one of your finished `veo-3.1-lite` videos. |
| `prompt` | string | yes | Required by the schema but not used for an upscale; any text of 3 or more characters. |
| `model` | string | no | `veo-3.1-lite` (default). |
| `webhook_url` | string | no | Public `https://` URL we POST to when the task starts, succeeds or fails. See Tasks & webhooks. |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/video/generations \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "veo-3.1-lite",
    "source_task_id": "task_mhx2k9q1_4f7a9c2e81b3",
    "prompt": "upscale"
  }'
```

Response `202`:

```json
{
  "task_id": "task_mhx3a1b2_9d0e1f2a3b4c",
  "status": "queued",
  "model": "veo-3.1-lite",
  "created_at": "2026-11-23T09:40:00.000Z"
}
```

Shortened. The new task delivers the 1080p file.

`reference_images` and `resolution: "720p"` cannot be combined with `source_task_id`.

Common errors:

- `400 VALIDATION_FAILED`: A field has a value this model does not accept, for example a video aspect ratio other than 16:9 or 9:16, or an image URL that is not public HTTPS. Fix the field named in the message and retry.
- `402 ALLOWANCE_EXHAUSTED`: This month’s videos or images are used up. Upgrade the plan in Plan & billing, or wait for the next paid month. GET /v1/usage shows what is left.
- `429 CONCURRENCY_LIMIT`: The API already runs as many renders as your plan allows at once. Wait for one to finish (poll GET /v1/tasks/{id}) and retry.

## Images

Nano Banana images from a prompt, optionally guided by reference images. By default the answer waits and returns the image links.

### Models

Each image counts as 1 image from your plan, whatever the model.

| Model | Good for | Reference images |
| --- | --- | --- |
| `nano-banana-2` (default) | Fast drafts, thumbnails, variants | Up to 4 |
| `nano-banana-2.1` | Consistent characters and storyboards | Up to 10 |
| `nano-banana-pro` | Photoreal shots and legible text in the image | Up to 10 |

### Create images: `POST /v1/images/generations`

Make 1 to 4 images from a prompt and get their links in the same answer.

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `prompt` | string | yes | What the image shows. 3 to 10,000 characters. |
| `model` | string | no | `nano-banana-2` (default), `nano-banana-2.1` or `nano-banana-pro`. |
| `n` | integer | no | How many images, `1` to `4` (default `1`). Each counts as 1 image. |
| `aspect_ratio` | string | no | `16:9` (default), `9:16`, `1:1`, `4:3` or `3:4`. |
| `size` | string | no | Instead of `aspect_ratio`: `1376x768`, `768x1376`, `1024x1024`, `1184x864` or `864x1184`. |
| `reference_images` | string[] | no | Images to follow: `https://` URLs or `data:image` URIs. Up to 4, or 10 on `nano-banana-2.1` and `nano-banana-pro`. |
| `seed` | integer | no | Same seed and prompt give a similar result. |
| `async` | boolean | no | `true`: answer `202` with a `task_id` at once instead of waiting; poll `GET /v1/tasks/{id}` for `image_urls`. |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/images/generations \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "nano-banana-pro",
    "prompt": "Product photo of a matte black water bottle on wet slate, soft morning light, shallow depth of field.",
    "aspect_ratio": "1:1",
    "n": 2
  }'
```

Response `200`:

```json
{
  "created": 1795431000,
  "data": [
    {
      "url": "https://avatarity.dev/v1/storage/object?token=example-signed-token-1"
    },
    {
      "url": "https://avatarity.dev/v1/storage/object?token=example-signed-token-2"
    }
  ]
}
```

The links are pre-signed and expire: download the files soon.

`503 CAPACITY_BUSY` only happens on the waiting call. Retry after `Retry-After`, or send `async: true` and the job waits in the queue by itself.

Common errors:

- `400 INVALID_PAYLOAD`: The JSON body failed the schema check. error.details names each field and what is wrong with it. Fix the fields named in error.details. Do not retry the same body unchanged.
- `400 VALIDATION_FAILED`: A field has a value this model does not accept, for example a video aspect ratio other than 16:9 or 9:16, or an image URL that is not public HTTPS. Fix the field named in the message and retry.
- `400 CONTENT_POLICY_VIOLATION`: The prompt or an input image was refused by the content check. Image calls answer 422 when the model refuses after starting. Nothing is counted. Change the prompt or the image. Real people, minors, sexual content, violence, public figures and copyrighted characters are the usual reasons. Do not resend the same content.
- `503 CAPACITY_BUSY`: Synchronous image calls (POST /v1/images/generations without async) only: the image could not start within the request, so nothing ran and nothing was counted. The response carries Retry-After and retry_after_seconds. Asynchronous jobs never get this answer: they wait in the queue instead. Retry after Retry-After, or send async: true: the job is accepted with 202 and status "queued", starts by itself and finishes later.
- `402 ALLOWANCE_EXHAUSTED`: This month’s videos or images are used up. Upgrade the plan in Plan & billing, or wait for the next paid month. GET /v1/usage shows what is left.
- `429 RATE_LIMIT_EXCEEDED`: This key sent more requests per minute than it may. Wait until X-RateLimit-Reset (seconds) has passed, then retry with backoff.

## Avatars

Talking-presenter videos: pick an avatar and a voice, send a script or an audio file, and get an MP4.

### Price and balance

Avatar 3 (`avatar-3`) costs $0.25 per minute of finished video, billed by the second. It is paid from avatar credits, which you buy as packs in the Studio under Billing; the plan's video allowance is not used.

The price of the requested length is held when the render starts. A shorter video gives the rest back, and a failed render gives everything back.

| Pack | Avatar 3 minutes |
| --- | --- |
| $30 | 120 min |
| $75 | 300 min |
| $150 | 600 min |
| $300 | 1,200 min |

### How a render works

1. `GET /v1/avatar/catalog` to pick an `avatar_id` and a `voice_id`. 2. `POST /v1/avatar/generate` with your script. 3. Renders of up to 20 seconds answer `200` with `video_url` when done; longer ones answer `202` with a `task_id`. 4. Poll `GET /v1/avatar/tasks/{id}` every 15 seconds until `status` is `completed` or `failed`.

Avatar tasks use `completed` where video and image tasks use `succeeded`.

### List avatars and voices: `GET /v1/avatar/catalog`

List the avatars (with their looks) and the voices you can use right now.

Example:

```bash
curl -sS https://avatarity.dev/v1/avatar/catalog \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "avatars": [
    {
      "id": "studio_avatar_anna",
      "name": "Anna",
      "gender": "female",
      "type": "preconfigured",
      "looks": [
        "office",
        "casual"
      ],
      "default_look": "office",
      "preview_image_url": "https://avatarity.dev/v1/storage/object?token=example-preview"
    }
  ],
  "voices": [
    {
      "id": "studio_voice_en_f1",
      "name": "Clara",
      "gender": "female",
      "language": "en-US"
    }
  ]
}
```

Shortened. Your own photo avatars are listed too.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

### Create an avatar video: `POST /v1/avatar/generate`

Render a talking-avatar video from a script (or an audio file).

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `model` | string | yes | `avatar-3`. |
| `avatar_id` | string | yes | From `GET /v1/avatar/catalog`, or the id of your own photo avatar. Or send `image_url` instead. |
| `script` | string | yes | What the avatar says (up to 10,000 characters). Or send `audio_url` instead. |
| `voice_id` | string | no | A voice from the catalog. Leave it out to use the avatar’s own voice. |
| `audio_url` | string | no | Public `https://` speech audio to lip-sync, instead of `script`. |
| `image_url` | string | no | Public `https://` portrait to animate, instead of `avatar_id`. |
| `aspect_ratio` | string | no | `16:9` (default), `9:16` or `1:1`. |
| `duration_seconds` | number | no | Expected length, 2 to 600 (default 10). Sets the hold; the charge follows the real length. |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/avatar/generate \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "avatar-3",
    "avatar_id": "studio_avatar_anna",
    "voice_id": "studio_voice_en_f1",
    "script": "Welcome to the product tour. In the next minute I will show you the three things that matter.",
    "aspect_ratio": "16:9",
    "duration_seconds": 30
  }'
```

Response `202`:

```json
{
  "task_id": "avatar_mhx4c5d6_1a2b3c4d",
  "status": "processing",
  "model": "avatar-3",
  "duration_seconds": 30,
  "links": {
    "query": "/v1/avatar/query?task_id=avatar_mhx4c5d6_1a2b3c4d"
  }
}
```

Up to 20 seconds the call waits and answers 200 with status "completed" and video_url.

`avatar-4` is not on sale yet and answers `400 AVATAR_MODEL_COMING_SOON`.

Common errors:

- `402 AVATAR_CREDITS_INSUFFICIENT`: The avatar balance does not cover the requested video length. Buy an avatar credit pack in the Studio under Billing, or send a shorter script.
- `400 VOICE_UNAVAILABLE`: Avatars: this voice_id cannot be used right now. Pick a voice from GET /v1/avatar/catalog, leave voice_id out to use the avatar’s own voice, or send audio_url.
- `400 AVATAR_MODEL_COMING_SOON`: Avatar 4 is not on sale yet. Send model "avatar-3".
- `429 AVATAR3_CONCURRENCY_LIMIT`: Your account already runs as many avatar renders at once as it may. Wait for one to finish (poll GET /v1/avatar/tasks/{id}) and retry.
- `429 AVATAR3_DAILY_BUDGET_EXHAUSTED`: Your avatar minutes for the last 24 hours are used up. The body has next_refill_at. Retry after next_refill_at, or send a shorter script.
- `429 RATE_LIMIT_EXCEEDED`: This key sent more requests per minute than it may. Wait until X-RateLimit-Reset (seconds) has passed, then retry with backoff.

### Get an avatar task: `GET /v1/avatar/tasks/{id}`

Check an avatar render and get its video link when it is done.

Fields (in the path):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The `task_id` from `POST /v1/avatar/generate`. |

Example:

```bash
curl -sS https://avatarity.dev/v1/avatar/tasks/avatar_mhx4c5d6_1a2b3c4d \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "task_id": "avatar_mhx4c5d6_1a2b3c4d",
  "status": "completed",
  "duration_seconds": 29,
  "progress_percent": 100,
  "video_url": "https://avatarity.dev/v1/storage/object?token=example-signed-token",
  "error": null,
  "created_at": "2026-11-23T09:30:00.000Z",
  "updated_at": "2026-11-23T09:34:10.000Z"
}
```

`status` is `processing`, `completed` or `failed`.

Common errors:

- `404 NOT_FOUND`: The task, render or resource does not exist on this account. Check the id. Tasks are visible only to the account that created them.

### List your photo avatars: `GET /v1/avatar/custom`

List the avatars you made from your own photos, with their looks.

Example:

```bash
curl -sS https://avatarity.dev/v1/avatar/custom \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "status": "success",
  "count": 1,
  "custom_avatars": [
    {
      "id": "av_usr_3f9a1c2b7d4e",
      "name": "Founder",
      "type": "custom",
      "looks": [
        "default"
      ],
      "default_look": "default",
      "provisioning_status": "ready",
      "created_at": "2026-11-23T09:00:00.000Z"
    }
  ]
}
```

Shortened.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

### Create a photo avatar: `POST /v1/avatar/custom`

Turn a portrait photo into an avatar (a new look) you can render with.

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | A name for the avatar. |
| `photo_url` | string | yes | Public `https://` portrait, face clearly visible. Or send `photo_base64` instead. |
| `gender` | string | no | `male`, `female` or `neutral` (default). |
| `default_voice` | string | no | Voice used when a render sends no `voice_id`. |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/avatar/custom \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Founder",
    "photo_url": "https://example.com/portraits/founder.jpg",
    "gender": "female"
  }'
```

Response `201`:

```json
{
  "status": "success",
  "avatar": {
    "id": "av_usr_3f9a1c2b7d4e",
    "name": "Founder",
    "type": "custom",
    "looks": [
      "default"
    ],
    "default_look": "default",
    "provisioning_status": "ready"
  },
  "provisioning": {
    "avatar_id": "av_usr_3f9a1c2b7d4e",
    "deduplicated": false,
    "default_look_id": "default"
  }
}
```

Shortened. Use avatar.id as avatar_id. The same photo twice returns the same avatar.

Only use photos of yourself or of people who agreed. The photo passes the content check first.

Common errors:

- `400 INVALID_AVATAR_NAME`: POST /v1/avatar/custom: the name field is missing. Send a name for the new avatar.
- `400 MISSING_PORTRAIT_SOURCE`: POST /v1/avatar/custom: no photo was sent. Send photo_url (a public https:// image) or photo_base64.
- `400 CONTENT_POLICY_VIOLATION`: The prompt or an input image was refused by the content check. Image calls answer 422 when the model refuses after starting. Nothing is counted. Change the prompt or the image. Real people, minors, sexual content, violence, public figures and copyrighted characters are the usual reasons. Do not resend the same content.

## Tasks & webhooks

Every video render, and every image request sent with async: true, becomes a task. Poll it, or let us call your webhook.

### Task status

`queued` → `processing` → `succeeded`, or `failed` / `cancelled`. Only `succeeded`, `failed` and `cancelled` are final.

Poll every 10 seconds. While queued, the task also shows `queue_position` and `est_start_seconds`. A failed task carries `error.code` and `error.message` and is not counted.

`video_url` and `image_urls` are pre-signed links that expire: download the files soon after `succeeded`.

### Webhooks

Add `webhook_url` to a video request and we POST to it on `task.started`, `task.succeeded` and `task.failed`. Answer with any 2xx within 5 seconds; a failed delivery is retried up to 3 times. Keep polling as a fallback.

Each delivery is signed (Standard Webhooks): headers `webhook-id`, `webhook-timestamp` and `webhook-signature` (`v1,<base64 HMAC-SHA256 of "id.timestamp.body">`). Get your signing secret once with `POST /v1/webhooks/secret/rotate` and verify every delivery.

Example delivery body:

```json
{
  "id": "evt_5b1f0c9e2a7d4e8f6a3b2c1d",
  "event": "task.succeeded",
  "taskId": "task_mhx2k9q1_4f7a9c2e81b3",
  "timestamp": "2026-11-23T09:31:42.000Z",
  "data": {
    "status": "succeeded",
    "video_url": "https://avatarity.dev/v1/storage/object?token=example-signed-token",
    "duration_seconds": 8
  }
}
```

### Verify a webhook (Node.js)

Reject any delivery whose signature does not match or whose timestamp is older than 5 minutes.

verify-webhook.ts:

```typescript
import crypto from 'node:crypto';

// rawBody: the request body exactly as received (before JSON.parse).
export function verifyAvatarityWebhook(rawBody: string, headers: Record<string, string | undefined>): boolean {
  const secret = process.env.AVATARITY_WEBHOOK_SECRET!; // whsec_... from POST /v1/webhooks/secret/rotate
  const id = headers['webhook-id'];
  const timestamp = headers['webhook-timestamp'];
  const signatures = headers['webhook-signature'];
  if (!id || !timestamp || !signatures) return false;
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false; // older than 5 minutes

  const key = secret.startsWith('whsec_') ? Buffer.from(secret.slice(6), 'base64') : Buffer.from(secret, 'utf8');
  const expected = crypto.createHmac('sha256', key).update(`${id}.${timestamp}.${rawBody}`).digest('base64');
  return signatures.split(' ').some((entry) => {
    const sig = entry.split(',')[1] ?? '';
    return sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
  });
}
```

### Get a task: `GET /v1/tasks/{id}`

Check a video or image task and get its result links when it is done.

Fields (in the path):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The `task_id` from the create call. |

Example:

```bash
curl -sS https://avatarity.dev/v1/tasks/task_mhx2k9q1_4f7a9c2e81b3 \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "task_id": "task_mhx2k9q1_4f7a9c2e81b3",
  "status": "succeeded",
  "model": "veo-3.1-lite",
  "progress_pct": 100,
  "video_url": "https://avatarity.dev/v1/storage/object?token=example-signed-token",
  "thumbnail_url": null,
  "created_at": "2026-11-12T09:30:00.000Z",
  "completed_at": "2026-11-12T09:31:42.000Z",
  "error": null
}
```

Image tasks carry image_urls instead of video_url.

Common errors:

- `404 TASK_NOT_FOUND`: GET /v1/tasks/{id} found no task with this id on your account. Use the task_id from the answer of the create call, with a key of the same account.
- `200 CAPACITY_TIMEOUT`: Task error (GET /v1/tasks/{id}, webhooks): the job waited in the queue for 5.5 hours without starting. Jobs never fail just because the queue is busy; they wait, and only this upper bound ends the wait. Nothing was charged. Submit the job again.

### Show the webhook secret: `GET /v1/webhooks/secret`

See which webhook signing secret is active (masked).

Example:

```bash
curl -sS https://avatarity.dev/v1/webhooks/secret \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "object": "webhook_secret",
  "masked_secret": "whsec_****Qk9z",
  "created_at": "2026-11-01T10:00:00.000Z",
  "signature_scheme": "standard-webhooks-v1"
}
```

Shortened.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

### Rotate the webhook secret: `POST /v1/webhooks/secret/rotate`

Create a new webhook signing secret; it is shown once.

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/webhooks/secret/rotate \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "object": "webhook_secret",
  "secret": "whsec_<new secret, shown once>",
  "masked_secret": "whsec_****bHk=",
  "created_at": "2026-11-23T09:00:00.000Z",
  "signature_scheme": "standard-webhooks-v1"
}
```

Store secret now. Deliveries are signed with the new secret from here on.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

## Account

Your plan, what is left this month, and your API keys.

### Get usage: `GET /v1/usage`

See your plan, what is left this month and how many renders run right now.

Example:

```bash
curl -sS https://avatarity.dev/v1/usage \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "plan": {
    "id": "pro",
    "name": "Pro",
    "price_cents": 7000,
    "currency": "USD",
    "concurrency": 4
  },
  "status": "active",
  "current_period_end": "2026-12-23T09:00:00.000Z",
  "allowances": {
    "veo": {
      "granted": 8000,
      "used": 120,
      "reserved": 2,
      "remaining": 7878
    },
    "images": {
      "granted": 20000,
      "used": 340,
      "reserved": 0,
      "remaining": 19660
    }
  },
  "concurrency": {
    "limit": 4,
    "in_flight": 1,
    "available": 3
  },
  "video_units": {
    "p720": 1,
    "p1080": 2,
    "upscale": 1
  }
}
```

Shortened. remaining is null on plans without a fixed cap.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

### List API keys: `GET /v1/tokens`

List the API keys on your account (never the full key).

Example:

```bash
curl -sS https://avatarity.dev/v1/tokens \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "object": "list",
  "data": [
    {
      "id": "av_live_9f81b2c4d5e6",
      "name": "Production",
      "scopes": [
        "*"
      ],
      "created_at": "2026-11-01T10:00:00.000Z",
      "last_used_at": "2026-11-23T09:30:00.000Z"
    }
  ],
  "total": 1
}
```

Shortened.

Common errors:

- `401 AUTHENTICATION_REQUIRED`: The request has no Authorization header, or it is not in the form Bearer <key>. Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys.

### Rotate an API key: `POST /v1/tokens/{id}/rotate`

Get a new secret for a key while the old one keeps working for a grace period.

Fields (JSON body):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (path) | yes | The key id from `GET /v1/tokens`. |
| `grace_period_ms` | integer | no | How long the old secret keeps working, in milliseconds (default `86400000`, 24 hours). |

Example:

```bash
curl -sS -X POST https://avatarity.dev/v1/tokens/av_live_9f81b2c4d5e6/rotate \
  -H "Authorization: Bearer $AVATARITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "grace_period_ms": 86400000
  }'
```

Response `200`:

```json
{
  "object": "token_rotation",
  "id": "av_live_9f81b2c4d5e6",
  "raw_key": "av_live_9f81b2c4d5e6_<new secret, shown once>",
  "grace_expires_at": "2026-11-24T09:30:00.000Z"
}
```

Store raw_key now; it is not shown again.

Common errors:

- `404 TOKEN_NOT_FOUND`: No API key with this id on your account. List your keys with GET /v1/tokens and use one of their ids.

### Revoke an API key: `DELETE /v1/tokens/{id}`

Switch a key off for good.

Fields (in the path):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The key id from `GET /v1/tokens`. |

Example:

```bash
curl -sS -X DELETE https://avatarity.dev/v1/tokens/av_live_9f81b2c4d5e6 \
  -H "Authorization: Bearer $AVATARITY_API_KEY"
```

Response `200`:

```json
{
  "success": true,
  "revoked_id": "av_live_9f81b2c4d5e6"
}
```

Shortened. Requests with this key fail from now on.

Common errors:

- `404 TOKEN_NOT_FOUND`: No API key with this id on your account. List your keys with GET /v1/tokens and use one of their ids.

## Errors

Every error has the same shape, a stable code and a next step.

### Error format

Errors answer with a 4xx or 5xx status and `{"error": {"code", "message", "doc_url"}}`. Branch on `error.code`, show `error.message` to people. Schema errors add `error.details` with one entry per field.

Retry only `429` and `503` answers (after `Retry-After` or `X-RateLimit-Reset`), and always with the same `Idempotency-Key`. Fix the request for every other `4xx`.

Example:

```json
{
  "error": {
    "code": "ALLOWANCE_EXHAUSTED",
    "message": "This month’s videos are used up.",
    "doc_url": "https://avatarity.dev/docs/errors#ALLOWANCE_EXHAUSTED"
  }
}
```

### Safety warnings

When many of your renders are refused by the content check, render and task answers carry `warnings: [{ "code": "SAFETY_REFUSALS_HIGH", ... }]` and an `X-Avatarity-Warning` header, and new renders may be slowed with `429 SAFETY_REFUSAL_COOLDOWN` until `cooldown_until`. Show the message and change the prompts or images; do not resend the same content.

### All error codes

| HTTP | Code | Meaning | What to do |
| --- | --- | --- | --- |
| 401 | `AUTHENTICATION_REQUIRED` | The request has no Authorization header, or it is not in the form Bearer <key>. | Send your key as Authorization: Bearer av_live_... on every /v1 call. Create one in the Studio under API keys. |
| 401 | `INVALID_TOKEN` | The API key is not valid (typo, wrong account, or deleted). | Copy the key again from the Studio under API keys, or create a new one. |
| 401 | `UNAUTHENTICATED` | The Studio session or API key is missing, invalid or expired. | Sign in again at /login, or send your key as Authorization: Bearer av_live_... |
| 401 | `TOKEN_REVOKED` | The API key was revoked or rotated and its grace period has ended. | Create a new key in the Studio under API keys and update your integration. |
| 403 | `INSUFFICIENT_SCOPE` | The API key is not allowed to call this endpoint. | Use a key created in the Studio; it covers video, image and avatar calls. |
| 403 | `IP_NOT_PERMITTED` | The request came from an address outside the key’s IP allowlist. | Call from an allowed address, or change the allowlist in the Studio under API keys. |
| 403 | `TENANT_SUSPENDED` | The account is suspended, so new renders and new API keys are blocked. | Contact support from the Studio Help page. |
| 403 | `ACCOUNT_PENDING_ACTIVATION` | The account is not activated yet, so it cannot render. | Finish the activation steps you were sent by email, or contact support. |
| 402 | `SUBSCRIPTION_REQUIRED` | There is no active plan on this account. | Choose a plan at /pricing or in the Studio under Plan & billing. |
| 402 | `ALLOWANCE_NOT_ACTIVE` | The plan exists but this month’s allowance is not active yet. | It appears as soon as the payment is confirmed, usually within a minute. |
| 402 | `ALLOWANCE_EXHAUSTED` | This month’s videos or images are used up. | Upgrade the plan in Plan & billing, or wait for the next paid month. GET /v1/usage shows what is left. |
| 402 | `FREE_LIMIT_REACHED` | The free account has used what it may render for now. | Wait for the limit to reset, or choose a plan at /pricing. |
| 402 | `PAYMENT_OVERDUE` | The last payment failed more than 72 hours ago, so new renders are paused. | Update your card under Plan & billing (Manage billing). Renders resume once paid. |
| 402 | `PAYMENT_DISPUTED` | The payment for this period is disputed, so the allowance is on hold. | Contact support at /support to resolve the dispute. |
| 402 | `AVATAR_CREDITS_INSUFFICIENT` | The avatar balance does not cover the requested video length. | Buy an avatar credit pack in the Studio under Billing, or send a shorter script. |
| 400 | `INVALID_PAYLOAD` | The JSON body failed the schema check. error.details names each field and what is wrong with it. | Fix the fields named in error.details. Do not retry the same body unchanged. |
| 400 | `VALIDATION_FAILED` | A field has a value this model does not accept, for example a video aspect ratio other than 16:9 or 9:16, or an image URL that is not public HTTPS. | Fix the field named in the message and retry. |
| 400 | `MODEL_NOT_AVAILABLE` | The model is not sold. Video: veo-3.1-lite. Images: nano-banana-2, nano-banana-2.1, nano-banana-pro. Avatars: avatar-3. | Use one of the listed models (GET /v1/models). |
| 400 | `CONTENT_POLICY_VIOLATION` | The prompt or an input image was refused by the content check. Image calls answer 422 when the model refuses after starting. Nothing is counted. | Change the prompt or the image. Real people, minors, sexual content, violence, public figures and copyrighted characters are the usual reasons. Do not resend the same content. |
| 400 | `VOICE_UNAVAILABLE` | Avatars: this voice_id cannot be used right now. | Pick a voice from GET /v1/avatar/catalog, leave voice_id out to use the avatar’s own voice, or send audio_url. |
| 400 | `AVATAR_MODEL_COMING_SOON` | Avatar 4 is not on sale yet. | Send model "avatar-3". |
| 400 | `INVALID_AVATAR_NAME` | POST /v1/avatar/custom: the name field is missing. | Send a name for the new avatar. |
| 400 | `MISSING_PORTRAIT_SOURCE` | POST /v1/avatar/custom: no photo was sent. | Send photo_url (a public https:// image) or photo_base64. |
| 202 | `MODERATION_HELD` | The prompt was flagged by an automatic check and waits for a short review. | Nothing is counted while it waits. You are notified of the outcome. |
| 404 | `NOT_FOUND` | The task, render or resource does not exist on this account. | Check the id. Tasks are visible only to the account that created them. |
| 404 | `TASK_NOT_FOUND` | GET /v1/tasks/{id} found no task with this id on your account. | Use the task_id from the answer of the create call, with a key of the same account. |
| 404 | `TOKEN_NOT_FOUND` | No API key with this id on your account. | List your keys with GET /v1/tokens and use one of their ids. |
| 409 | `IDEMPOTENT_OPERATION_IN_FLIGHT` | A request with the same Idempotency-Key is still being accepted. | Wait a second and retry with the same key; you then get the answer and task id of the first request. |
| 409 | `IDEMPOTENCY_CONFLICT` | This Idempotency-Key was already used for a request that did not create a task. | Send the request again with a new Idempotency-Key. |
| 429 | `CONCURRENCY_LIMIT` | The API already runs as many renders as your plan allows at once. | Wait for one to finish (poll GET /v1/tasks/{id}) and retry. |
| 429 | `AVATAR3_CONCURRENCY_LIMIT` | Your account already runs as many avatar renders at once as it may. | Wait for one to finish (poll GET /v1/avatar/tasks/{id}) and retry. |
| 429 | `AVATAR3_DAILY_BUDGET_EXHAUSTED` | Your avatar minutes for the last 24 hours are used up. The body has next_refill_at. | Retry after next_refill_at, or send a shorter script. |
| 429 | `RATE_LIMIT_EXCEEDED` | This key sent more requests per minute than it may. | Wait until X-RateLimit-Reset (seconds) has passed, then retry with backoff. |
| 429 | `RATE_LIMITED` | Too many requests in a short time (Studio). | Wait and retry; the Retry-After header says how long. |
| 429 | `QUEUE_FULL` | Studio only: too many renders are running or waiting. | Start more when some have finished. |
| 429 | `SAFETY_REFUSAL_COOLDOWN` | Many of your recent renders were refused by the safety filter, so new renders are slowed down for a while: one at a time for 10 minutes after 6 refusals in 30 minutes (when at least a fifth of your finished renders were refused), and a 5-minute pause if 4 renders submitted in that time are refused too, then one at a time again. The body has retry_after, reason (paused or concurrency), tier, limits, resets_at and cooldown_until. cooldown_until is fixed when the limit starts and is the same on every answer. It is not a ban, and renders already queued keep running. | Change the prompts or input images before you retry. Common reasons for refusals: real people or minors, sexual content, violence, public figures and copyrighted characters. Two successful renders in a row end the one-at-a-time limit early; render and status responses carry a SAFETY_REFUSALS_HIGH entry in warnings[] (and an X-Avatarity-Warning header) from 3 refusals in 30 minutes on. |
| 503 | `BILLING_UNAVAILABLE` | Usage accounting is briefly unavailable. | Retry in a moment with the same Idempotency-Key. Nothing was started or counted. |
| 503 | `CAPACITY_BUSY` | Synchronous image calls (POST /v1/images/generations without async) only: the image could not start within the request, so nothing ran and nothing was counted. The response carries Retry-After and retry_after_seconds. Asynchronous jobs never get this answer: they wait in the queue instead. | Retry after Retry-After, or send async: true: the job is accepted with 202 and status "queued", starts by itself and finishes later. |
| 200 | `CAPACITY_TIMEOUT` | Task error (GET /v1/tasks/{id}, webhooks): the job waited in the queue for 5.5 hours without starting. Jobs never fail just because the queue is busy; they wait, and only this upper bound ends the wait. Nothing was charged. | Submit the job again. |
