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

# Generate images and video with the API

> Start an image or video run with POST /v1/runs: pick a workflow slug, set the prompt, cast a character, then poll the run and download its outputs.

A run renders one workflow, named by its slug, with your prompt and your character. You start it, poll it until it settles, then download what it made.

**Build a character and generate with it.** Paste into Cursor, Claude Code or Codex to add the Omnichar API to your project.

Add an Omnichar integration to this project that builds a character from face photos and generates an image with it.

Inspect this codebase's stack and existing patterns first and follow them. Read these docs before writing code: `https://docs.omnichar.org/api/quickstart.md`, `https://docs.omnichar.org/api/uploads.md`, `https://docs.omnichar.org/api/characters.md`, `https://docs.omnichar.org/api/runs.md`. The full index is `https://docs.omnichar.org/llms.txt`.

Base URL `https://api.omnichar.org/v1`. Send `Authorization: Bearer` with the key from the `OMNICHAR_API_KEY` environment variable. The key needs the scopes `chars:write`, `chars:read`, `runs:write` and `runs:read`.

1. `GET /team` and confirm `env` is `sandbox`. On 401 or 403, stop and tell me the key or its scopes are wrong.
2. For each of 4 or more face photos: `POST /uploads`, then PUT the bytes to `uploadUrl` with exactly the returned `headers`. Keep each `upload_key`.
3. `POST /chars` with a `subject_id` and the upload keys in `references.face`. Send an `Idempotency-Key` built from the `subject_id`.
4. Wait until `GET /chars/{id}` says `ready`, with backoff. Stop on `failed` and show `failure_reason`.
5. `POST /runs` with slug `default-flux-2-klein-4b`, the prompt in `inputs.prompt.text`, the character in `characters.character.char_id`, and a fresh `Idempotency-Key` per run.
6. Poll `GET /runs/{id}` every few seconds until `succeeded`, `failed` or `canceled`. Runs have no webhook.
7. `GET /runs/{id}/outputs` and download each `url` straight away into `./omnichar-out/`. The links expire.

Hard rules:

* The API key stays server side. Never put it in client code, a bundle, a log or an error message.
* Use only an `sk_test_` key while building.
* In production, listen for the `char.ready` webhook instead of polling the build.
* Retry 429 and 5xx with backoff and the same `Idempotency-Key`. Treat other 4xx answers as final.

Done when: in sandbox, the character reaches `ready`, the run reaches `succeeded`, and its output file is saved. Print the character id and run id, never the key.

You need a key with `runs:write` to start runs and `runs:read` to read them. New keys don't have either, so tick both when you create the key. See [Authentication](https://docs.omnichar.org/api/authentication.md).

## Start a run

`POST /v1/runs` · scope `runs:write`

```bash theme={null}
curl -s -X POST https://api.omnichar.org/v1/runs \
  -H "Authorization: Bearer $OMNICHAR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: run-0001" \
  -d '{
    "slug": "default-flux-2-klein-4b",
    "inputs": { "prompt": { "text": "studio portrait, soft window light" } },
    "characters": { "character": { "char_id": "7f1c2a9e-..." } }
  }'
# -> {"runId":"0b6e...","status":"queued"}
```

| Field | Required | Notes |
| - | - | - |
| `slug` | yes | The workflow to run. See [Workflows](#workflows). |
| `inputs` | no | Settings by node and then by setting. The prompt is `inputs.prompt.text`. A setting you leave out keeps the workflow's default. |
| `characters` | no | The character to cast, as `{ "char_id": "..." }`. Use the key `character` when the workflow has one character field, as every workflow below does. |
| `license_context` | only for licensed characters | The use and territory of a run that casts a character another team licensed to you. See [License context](https://docs.omnichar.org/api/license-context.md). |

`char_id` is the id of a character you created with [`POST /v1/chars`](https://docs.omnichar.org/api/characters), one licensed to your team, or one you built in Omnichar Cloud.

A name the workflow does not have is refused with `422`, and the error lists the names it accepts:

```json theme={null}
{
  "error": {
    "code": "unprocessable",
    "message": "The inputs do not fit default-flux-2-klein-4b.",
    "details": { "errors": [{ "key": "hero", "message": "Not a character input of this workflow. It takes: character_load.file, character_load, character." }] }
  }
}
```

Send an `Idempotency-Key` so a retried request does not start a second run. See [Safe retries](https://docs.omnichar.org/api/idempotency.md).

## Workflows

Every workflow takes its prompt in `inputs.prompt.text`.

| Slug | Output | Character | Other settings |
| - | - | - | - |
| `default-flux-2-klein-4b` | Image | Optional | `black_forest_labs_flux_2`: `width`, `height`, `steps`, `seed`, `guidance`, `sampler`, `scheduler` |
| `default-flux-2-klein-9b` | Image | Optional | the same as Klein 4B |
| `default-z-image-turbo` | Image | None | `alibaba_z_image_turbo`: `width`, `height`, `steps`, `seed`, `guidance`, `sampler`, `scheduler` |
| `minimax-h3-text-to-video` | Video | None | `video`: `duration`, `resolution`, `aspect_ratio` |
| `minimax-h3-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |
| `seedance-2-5-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |
| `seedance-2-5-flash-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |
| `seedance-2-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |
| `wan-3-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |
| `happyhorse-1-1-reference-to-video` | Video | Required | `video`: `duration`, `resolution`, `aspect_ratio` |

"Required" means the run is refused unless it casts a character or brings a reference image. For video, `duration` is 5 to 15 seconds and `resolution` defaults to `480p`. `aspect_ratio` is one of `16:9`, `9:16`, `1:1`, `4:3`, `3:4` or `21:9`, and the reference workflows also take `adaptive`, their default. A value a model doesn't offer is refused with `422`.

The dashboard offers a few more workflows. They are left out here because they may change without notice.

```json theme={null}
{
  "slug": "wan-3-reference-to-video",
  "inputs": {
    "prompt": { "text": "she walks toward the camera on a rainy street at night" },
    "video": { "duration": 5, "aspect_ratio": "9:16" }
  },
  "characters": { "character": { "char_id": "7f1c2a9e-..." } }
}
```

What each run costs is on [Pricing](https://docs.omnichar.org/cloud/pricing.md).

## Wait for the run

`GET /v1/runs/{id}` · scope `runs:read`

```bash theme={null}
curl -s https://api.omnichar.org/v1/runs/$RUN_ID -H "Authorization: Bearer $OMNICHAR_API_KEY"
# -> {"id":"0b6e...","status":"running", ...}
```

`status` moves through `queued`, `dispatching` and `running` to one of `succeeded`, `failed` or `canceled`. A failed run carries `error.message`. Runs send no webhooks, so poll every few seconds, backing off as the run gets older. An image usually takes under a minute and a video a few minutes.

## Get the outputs

`GET /v1/runs/{id}/outputs` · scope `runs:read`

```bash theme={null}
curl -s https://api.omnichar.org/v1/runs/$RUN_ID/outputs -H "Authorization: Bearer $OMNICHAR_API_KEY"
```

```json theme={null}
{
  "runId": "0b6e...",
  "status": "succeeded",
  "outputs": [
    {
      "id": "95a5...",
      "mediaKind": "image",
      "bytes": 1187903,
      "url": "https://...",
      "thumbUrl": "https://...",
      "expiresAt": "2026-11-23T19:15:00.000Z",
      "continuity": { "continuityScore": 85.2, "...": "..." }
    }
  ]
}
```

Download each `url` before `expiresAt`. Ask for the outputs again to get fresh links. `continuity` is the identity match score explained in [Scoring](https://docs.omnichar.org/cloud/scoring.md).

## In sandbox

With an `sk_test_` key, a run goes through the same checks, including the input names above, then finishes about 10 seconds later with a placeholder: a grey image, or a short clip for video. Nothing is charged. See [Sandbox](https://docs.omnichar.org/api/sandbox.md).

## Errors

| Status | Code | When |
| - | - | - |
| `402` | `insufficient_credits` | Your balance does not cover the run. |
| `403` | `forbidden` | The key lacks `runs:write`, or a license check refused the run. |
| `404` | `not_found` | No ready character with that `char_id` for your team. |
| `422` | `unprocessable` | An unknown slug, input name or setting value, or a workflow that needs a character and got none. |

See [Errors](https://docs.omnichar.org/api/errors.md) for the full list.


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