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

# Video generation

> Submit a video task, poll its status and download the MP4 — the same three steps for every video model.

Video generation is an **asynchronous task**:

1. `POST /v1/videos` submits the task and returns its `id`.
2. `GET /v1/videos/{id}` reports progress until `status` is `completed` or `failed`.
3. `GET /v1/videos/{id}/content` downloads the MP4.

All requests use `Authorization: Bearer YOUR_API_KEY`. The request shape follows the OpenAI Videos API; model-specific options go in `metadata` or in the fields listed on each model page.

| Model | Page |
| - | - |
| `magi-2` | [MAGI-2](https://docs.refillapi.com/api/videos/magi-2.md) |
| `MiniMax-H3`, `MiniMax-H3-Max` | [MiniMax-H3](https://docs.refillapi.com/api/videos/minimax-h3.md) |
| `wan3.0-video-prime`, `wan3.0-video`, `wan2.7-t2v`, `wan2.7-i2v` | [Wan](https://docs.refillapi.com/api/videos/wan.md) |

## 1. Submit

```bash theme={null}
curl https://refillapi.com/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "prompt": "A corgi running along the beach at sunrise, the camera slowly tracking it",
    "seconds": 5
  }'
```

```json theme={null}
{
  "id": "task_xxxxxxxx",
  "object": "video",
  "model": "magi-2",
  "status": "queued",
  "progress": 0
}
```

## 2. Poll

```bash theme={null}
curl https://refillapi.com/v1/videos/task_xxxxxxxx \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```json theme={null}
{
  "id": "task_xxxxxxxx",
  "object": "video",
  "model": "magi-2",
  "status": "completed",
  "progress": 100
}
```

| `status` | Meaning |
| - | - |
| `queued` | Waiting to start |
| `in_progress` | Generating; `progress` goes from 0 to 100 |
| `completed` | Done — download it |
| `failed` | Failed; `error.message` says why, and the charge is refunded |

A video takes from about a minute to half an hour depending on the model, length and load. Poll every 15–30 seconds; faster polling does not make it finish sooner.

```json theme={null}
{
  "id": "task_xxxxxxxx",
  "object": "video",
  "status": "failed",
  "progress": 100,
  "error": { "code": "task_failed", "message": "Your request was rejected by content moderation." }
}
```

> [!WARNING]
>
> A `200` from the poll endpoint only means the lookup worked — always check `status`. On `failed`, stop polling and show `error.message`. Do not resubmit automatically: the same input usually fails the same way.

## 3. Download

```bash theme={null}
curl -L https://refillapi.com/v1/videos/task_xxxxxxxx/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o video.mp4
```

> [!WARNING]
>
> Download the video soon after the task completes and keep your own copy. Output links expire — plan on **24 hours**. After that the download endpoint returns an error and the video cannot be recovered.

## Input files

First frames, last frames and reference media must be **public `http(s)` URLs**. Base64 and file uploads are not accepted, except where a model page says otherwise. Make sure the URL is reachable without cookies or sign-in.

## Billing

Video is billed by the second. When you submit, the cost of the requested length is held from your balance; when the task finishes, it is settled against the actual length, and a failed task is refunded in full. Prices per second are on [Models & pricing](https://refillapi.com/pricing).

## Common errors

| Error | Cause |
| - | - |
| `prompt is required` | No prompt (and no image for image-to-video models) |
| `seconds must be an integer between …` | Length outside the model's range |
| `… must be a public HTTP or HTTPS URL …` | An input is not a public URL |
| `… is not supported; supported fields are …` | A `metadata` field the model does not accept |

See also [Errors](https://docs.refillapi.com/errors.md).


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