# Generate video

> Queues a video generation and returns the task straight away. Video takes minutes rather than seconds, so a webhook is the better way to hear about it than polling.

Creates a video task on the model you name. There is no `auto` and no
`count`: one request renders one video. A render takes minutes, so plan for a
[webhook](https://mynth.io/docs/concepts/webhooks.md) rather than holding a request open.

Resolution, duration, audio, and frame inputs are checked against the model at
create. [Video models](https://mynth.io/docs/models/video.md) lists what each model accepts, and
[generate video](https://mynth.io/docs/guides/generate-video.md) covers the result.

`POST /video/generate`

**Auth:** API key or OAuth token

## Request body

- `model` (required, string) — One of: `"bytedance/seedance-2.0-mini"`, `"google/gemini-omni-flash-1.1"`, `"prunaai/p-video"`, `"xai/grok-imagine-video-1.5"`. Example `"bytedance/seedance-2.0-mini"`.
- `prompt` (required, string) — Positive prompt. ≥ 1 characters, ≤ 8192 characters. Example `"A cat surfing a wave at sunset"`.
- `access` (object) — Controls whether the create-task response should include a short-lived Public Access Token. That token can be passed to browser or client-side code for polling task status and task videos without exposing your API key.
  - `pat` (required, object)
    - `enabled` (boolean) — Default `true`.
- `audio` (boolean) — Enable model-native generated audio. Only supported by models with audio capability.
- `duration` (number) — Video duration in seconds. Defaults to the model's default duration. ≥ 1, ≤ 60.
- `inputs` ((string | object)[]) — ≤ 5 items.
  - **source + type**
    - `source` (required, object)
      - `type` (required, "url")
      - `url` (required, string)
    - `type` (required, "image")
    - `as` (string) — One of: `"auto"`, `"first_frame"`, `"last_frame"`, `"reference"`.
- `metadata` (object)
- `negative_prompt` (string) — ≤ 8192 characters.
- `resolution` (string) — Resolution tier. Defaults to the model's default tier. One of: `"1080p"`, `"480p"`, `"4k"`, `"720p"`.
- `webhook` (object)
  - `custom` (object[]) — ≥ 1 items, ≤ 5 items.
    - `url` (required, string)
  - `dashboard` (boolean) — Set to false to disable dashboard-managed webhooks for this task. Request-level custom webhooks are still sent.

## Response

### 201 — Video generation task created

- `data` (required, object)
  - `estimatedCost` (required, string) — Estimated cost in USD reserved for this task. Failed videos are refunded, so the final cost may be lower. Example `"0.05"`.
  - `taskId` (required, string) — Task ID Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.
  - `access` (object) — Returned when `access.pat.enabled` is true. Currently the generate endpoint only returns a Public Access Token.
    - `publicAccessToken` (required, string) — Short-lived Public Access Token for polling task status and video results. This token is safe to return to frontend code and can be used instead of your API key for polling public task state. Example `"pat_eyJhbGciOi..."`.

```json
{
  "data": {
    "estimatedCost": "0.05",
    "taskId": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "access": {
      "publicAccessToken": "pat_eyJhbGciOi..."
    }
  }
}
```

### 400 — Validation Error

- `success` (required, false)
- `error` (required, array)
- `data` (required, any)

```json
{
  "success": false,
  "error": []
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/video/generate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedance-2.0-mini",
    "prompt": "A cat surfing a wave at sunset"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/video/generate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "bytedance/seedance-2.0-mini",
    "prompt": "A cat surfing a wave at sunset"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
