# kwirk API (kwirk 1.0)

Everything about the kwirk API in one file, written so you can paste it into your own AI assistant.
Human version with a playground: https://kwirk.ai/developers/

kwirk 1.0 is kwirk's own video model. It makes:
- **Imagine**: a video from a short idea (text, plus characters and images if you like). kwirk writes the whole video itself: shots, cuts, sound. 5 to 60 seconds.
- **Trend**: your characters in one of today's trending videos (same moves, camera and timing). No prompt needed.
- **Swap**: your characters in your own clip. No prompt needed.
- **Reference**: a new video that follows your clip (its motion, or just as inspiration).
- **Edit** and **Extend**: change one of your videos, or continue it up to 60 seconds in all.
- **Characters**: made once (from a photo, a description, or Surprise me realistic | crazy) and the same in every video.
- **Photos**: still images with your characters.

## Basics

- Base URL: `https://kwirk.ai/v1`
- Auth: `Authorization: Bearer kw_live_…` on every request, from your server only. Keys are made at https://kwirk.ai/developers/ (sign in, creator mode). A key is shown once. A deleted key stops at once.
- JSON in, JSON out.
- `Idempotency-Key` header on POST /v1/videos: the same key never starts or charges a second video.
- Balance: prepaid in US dollars (top up by card from $5 on the developers page). Money is held when a request starts and taken when it succeeds. Failed videos are refunded.
- 1 video at once to start, 3 at once after $100 topped up in total, more on request.
- Videos at once: 1 to start, 3 in a calendar month in which you top up $100, 20 in one in which you top up $1,000 (starts again on the 1st, UTC), more on request.
- Limits: clips up to 30 seconds and 200 MB, photos up to 10 MB, up to 6 people in a trend or clip video (10 in imagine; from 4 people a video takes a few minutes longer), 300 requests a minute per key.

## Prices (per second of finished video)

| Mode | 1080p | 4K |
|---|---|---|
| Imagine | $0.049 | $0.098 |
| Trend | $0.069 | $0.138 |
| Reference | $0.069 | $0.138 |
| Swap | $0.069 | $0.138 |
| Edit and Extend | $0.069 | $0.138 |

Whole seconds. A character from a photo or Surprise me: $0.30. Keeping a found voice for a character: $0.15. Partners and larger volumes get their own offer: write to us.

## Endpoints

| Method | Path | What |
|---|---|---|
| GET | /v1/account | Balance, videos at once, running, prices |
| GET | /v1/trends | Today's trends: `q`, `limit` (≤ 100), `cursor` |
| GET | /v1/trends/{id} | One trend |
| POST | /v1/characters | A new character (see Characters) |
| GET | /v1/characters | Your characters, newest first: `limit`, `cursor`, `external_user_id`, `source` api / app / all |
| GET | /v1/characters/{id} | `processing` / `ready` / `failed`, with `image_url` and `versions` |
| POST | /v1/characters/{id}/edit | Change the character: `change` (plain words) and/or `style` realistic / crazy. A new version is drawn (character price) and used from then on |
| POST | /v1/characters/{id}/versions/{version_id}/use | That version is used in videos from now on. Free |
| DELETE | /v1/characters/{id} | Deletes the character, its sheets and photos for good |
| POST | /v1/characters/{id}/voice/find | 3 voices that fit the character (optional `description`), to listen to. Free |
| POST | /v1/characters/{id}/voice/keep | `option` (0–2): that voice becomes the character's own voice ($0.15) |
| POST | /v1/ideas | Surprise me: one short video idea for `characters` (ids, optional), `look`, `language`, `avoid`. $0.01, 3 an hour |
| POST | /v1/videos | Make a video (see Modes) |
| GET | /v1/videos/{id} | `queued` / `running` / `succeeded` / `failed`, `progress`, `video_url` |
| GET | /v1/videos | Your videos, newest first: `limit`, `cursor`, `external_user_id`, `status` |
| DELETE | /v1/videos/{id} | Deletes the video for good (once done or failed) |
| POST | /v1/photos | Make a photo (see Photos) |
| GET | /v1/photos/{id} | `queued` / `running` / `succeeded` / `failed`, `image_url` |
| GET | /v1/photos | Your photos: `limit`, `cursor`, `external_user_id`, `status` |
| DELETE | /v1/photos/{id} | Deletes the photo for good |
| DELETE | /v1/end-users/{external_user_id} | Deletes everything made for one of your users |

## POST /v1/videos: modes

Every request has `mode` plus the fields of that mode.

- `imagine`: `prompt` (+ `characters`, `image_urls` (up to 9), `audio_urls` (up to 5 sound files, 30 s each), `video_url` (one video: then it is a `reference` video, up to 30 s, priced like Swap), `seconds` 5–60, `aspect_ratio` 9:16 | 3:4 | 1:1 | 4:5 | 16:9, `look` real | cinematic | exact (your prompt word for word), `voice` default | own | similar). Or `surprise: true` instead of `prompt`: kwirk writes the idea from your characters and images. To see the idea first, POST /v1/ideas ($0.01) and send it as `prompt`. The story is planned over the whole length you ask for.
- `trend`: `trend_id` + `characters` (+ `prompt` for anything else).
- `reference`: `video_url` + `prompt` (+ `characters`, `image_urls`, `audio_urls`, `reference_use`, `look`, `voice`). The same as `imagine` with a `video_url`. `reference_use`: `motion` (your video sets the moves and camera, default), `inspiration`, `edit` (we keep your video and change what you write; it keeps its length and format) or `extend` (your video goes on by `seconds`, up to 60 s in all; only the new seconds are paid).
- `swap`: `video_url` + `characters` (+ `others` change | keep: the other people in the clip).
- `edit`: `video_id` + `prompt`: what to change in one of your videos (+ `characters` to bring someone in). It keeps its length and format. For a video of your own use `reference` with `reference_use: "edit"`.
- `extend`: `video_id` + `prompt` + `seconds` (from 5 up to 60 s for the whole video, e.g. a 12-s video by up to 48 s): what happens next. It continues seamlessly; you get the whole video back. Only the new seconds are paid. The video's own characters stay in, so their faces stay the same; send `characters` to pick others, or `"characters": []` for none.

Fields for every mode:
- `resolution`: `1080p` (default) or `4K`.
- `characters`: a list of character ids from POST /v1/characters, or `{"photo_url": "…"}` to make one on the way (it becomes a character sheet first: best results, the character price once, ready to use again). With `{"photo_url": "…", "as_is": true}` the photo goes in as it is: free, but a sheet works better.
- In a prompt (Imagine, Reference), name your characters by first name (`@Mia`) or as `@Character1`, `@Character2` … in the order of `characters`, and your files as `@Image1` …, `@Audio1` …, `@Video1`.
- `look` (Imagine, Reference): `real` = looks like a real phone video (default), `cinematic` = a film look, `exact` = your prompt is sent word for word.
- `voice` (Imagine, Reference): `own` = characters with a saved voice speak in it (the same voice in every video), others get a similar voice; `similar` = every voice is made with the video; `default` = own when one of the characters has a saved voice. Songs always keep a similar voice. Trends and swaps keep the clip's sound.
- `ai_label`: `true` (default) = the file carries one tag, `comment = kwirk AI`, and nothing else. `false` = a completely clean file with no metadata at all, so you can add your own label.
- `external_user_id`: your id of the end user (≤ 128 characters).
- `metadata`: your own JSON, sent back with the video.
- `webhook_url`: we POST to it when the video is done.

Example:

```
curl https://kwirk.ai/v1/videos \
  -H "Authorization: Bearer kw_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1234" \
  -d '{
    "mode": "imagine",
    "prompt": "@Character1 tries to squeeze into a tiny red city car in a supermarket parking lot; the whole car sinks to one side when he finally gets in.",
    "characters": ["a1b2c3d4e5f6"],
    "seconds": 10,
    "resolution": "1080p",
    "webhook_url": "https://example.com/kwirk"
  }'
```

Answer (201):

```
{"id": "175a65b8c09b", "object": "video", "status": "queued", "mode": "imagine", "seconds": 10,
 "resolution": "1080p", "price_usd": 0.49, "progress": 0, "video_url": null, "error": null, "metadata": {}}
```

Poll GET /v1/videos/{id} (every 10–20 s) or wait for the webhook. Done: `"status": "succeeded"`, `"video_url": "https://…/final.mp4?…"`. A video takes about 3 to 6 minutes (longer ones and 4K a bit more).

## Characters

```
curl https://kwirk.ai/v1/characters -H "Authorization: Bearer kw_live_..." -H "Content-Type: application/json" \
  -d '{"photo_url": "https://example.com/mia.jpg", "name": "Mia"}'
```

- From a photo: `photo_url` or `image` (base64). `more_photo_urls`: up to 3 more photos of the same person (all go into one sheet). `sheet: true`: the picture is used as it is (any photo, or your own sheet in any layout) instead of drawing a new sheet; same price, saved like any character.
- Without a photo: `surprise` = `realistic` or `crazy`, or `description` + `style` (realistic | crazy).
- Optional: `name`, `external_user_id`, `metadata`, `webhook_url`.
- Ready in a minute or two (`status: ready`). A video started meanwhile waits for it.
- A saved voice (voice/find, then voice/keep) makes the character speak the same in every video.
- Change it: POST /v1/characters/{id}/edit `{"change": "give her a red leather jacket"}` (or `"style": "crazy"`) draws a new version at the character price; when it is `ready` again, videos use it. Every version stays in `versions` (`id`, `image_url`, `in_use`); POST /v1/characters/{id}/versions/{version_id}/use switches back, free.

## Photos

POST /v1/photos: `prompt`, `character` (an id or a photo), `characters` (more ids), `images` [{`url`, `use`: pose | outfit | hair | shoes | place | person}], `aspect_ratio`, `resolution` 1K | 2K, `look` phone | amateur | pro | auto, `exact` (your prompt word for word), `profile_picture`.

## Serving your own users

Send `external_user_id` with every character, video and photo. List one user's things with `?external_user_id=`. When a user leaves, DELETE /v1/end-users/{external_user_id} removes everything made for them. Everything made through the API stays out of the kwirk app's Library. `video_url` / `image_url` links are signed and run out after a day: GET again for a fresh one, or copy the file to your own storage.

Data: characters and videos are kept until you delete them; uploaded reference files are deleted after 30 days. User videos are never used for training. Automatic safety checks run on every request (nudity, famous people, minors).

## Webhooks

Events: `video.succeeded`, `video.failed`, `photo.succeeded`, `photo.failed`, `character.ready`, `character.failed`.

```
POST https://example.com/kwirk
Kwirk-Signature: t=1764252000,v1=5f0c…

{"event": "video.succeeded", "created": 1764252000, "data": { …the video, as GET /v1/videos/{id}… }}
```

Signature: hex = HMAC-SHA256(secret, t + "." + raw body). Answer 2xx; we try three times.

Python:

```
import hashlib, hmac, time

def verify(raw: bytes, header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw, hashlib.sha256).hexdigest()
    return abs(time.time() - int(parts["t"])) < 300 and hmac.compare_digest(expected, parts["v1"])
```

## Errors

Errors come as `{"error": {"code": "…", "message": "…"}}`.

| Code | HTTP | Meaning |
|---|---|---|
| invalid_request | 400 | A field is missing or wrong; the message says which |
| missing_key / invalid_key | 401 | No key, or a deleted one |
| insufficient_balance | 402 | Top up. Nothing was started |
| not_found | 404 | No such trend, character or video on your account |
| no_voice | 409 | Find voices first, then keep one |
| content_refused | 422 | The words or files break the content rules (also famous people and children) |
| permission_required | 422 | A file came without the permission statement |
| voice_required | 422 | `voice` own, but no character has a saved voice |
| too_many_running | 429 | All your videos at once are busy: retry after `Retry-After` seconds |
| rate_limited | 429 | More than 300 requests a minute on one key |

Questions or partner prices: https://kwirk.ai/contact/?topic=sales
