---
title: Video tasks API · Unified v1
description: Create, query and download Tokenlio asynchronous video tasks, including Wan and HappyHorse.
outline: [2, 3]
---

# Video tasks API · Unified v1

::: info API version
This page describes the **Unified Video API (v1)**. You can independently choose the [Seedance Native API (v3)](/api/seedance/) instead; use the request and result format documented for your chosen interface.
:::

::: info Model capabilities and optional controls
Only specifications and modes currently available for the requested API model ID can be used. Ranges on this page are interface limits, not a guarantee that every model ID supports every combination. Unsupported durations, resolutions, input counts or modes are rejected with `VIDEO_REQUEST_INVALID`; do not retry the same unsupported request.

Optional controls `generate_audio`, `return_last_frame`, `seed`, `watermark` and `output_format` may have no effect or use a default when unsupported. Defaults describe the request, not a guarantee of generated audio, a final frame, repeatable output or a particular container. Check the actual `assets` and downloaded file. Unknown fields, invalid types and `null` are still rejected.
:::

Video and image tasks share `GET /v1/tasks/{id}` and `GET /v1/tasks/{id}/content`. Use create → query → download. Image results use roles `image_0`–`image_3`.

**Create → query → download.** Use your Workspace API Key to create a video task, query its ID, and download the result when complete.

## Choose a model

| Model | Output duration | Resolution | Reference inputs | Reference |
| --- | --- | --- | --- | --- |
| **Seedance 2.0** | 4–15 integer seconds | 480p / 720p / 1080p / 4k | Up to 9 images, 3 videos, 3 audio clips | [Parameters and examples](/api/videos/seedance-2-0) |
| **Seedance 2.0 Fast** | 4–15 integer seconds | 480p / 720p | Up to 9 images, 3 videos, 3 audio clips | [Parameters and examples](/api/videos/seedance-2-0-fast) |
| **Seedance 2.0 Mini** | 4–15 integer seconds | 480p / 720p | Up to 9 images, 3 videos, 3 audio clips | [Parameters and examples](/api/videos/seedance-2-0-mini) |
| **Seedance 2.5** | 4–30 integer seconds | 480p / 720p / 1080p | Up to 30 images, 10 videos, 10 audio clips; audio-only references allowed | [Parameters and examples](/api/videos/seedance-2-5) |
| **MiniMax H3** | 4–15 integer seconds | 2k / 768p | Up to 9 images, 3 videos, 3 audio clips | [Parameters and examples](/api/videos/minimax-h3) |
| **MiniMax H3 Max** | 5–15 integer seconds | 480p / 768p / 1080p | Up to 9 images, 3 videos, 3 audio clips | [Parameters and examples](/api/videos/minimax-h3-max) |
| **Grok Imagine Video** | 1–15 integer seconds | 480p / 720p | 1–50 images; Base also edits one video | [Parameters and examples](/api/videos/grok-imagine-video) |
| **Grok Imagine Video 1.5** | 1–15 integer seconds | 480p / 720p / 1080p | 1–50 reference images; no editing | [Parameters and examples](/api/videos/grok-imagine-video-1-5) |
| **Wan 3.0** | 2–30 / -1 | 480p / 720p / 1080p | Reference images / video / audio / document / webpage | [Parameters and examples](/api/videos/wan3-0-video) |
| **Wan 3.0 Prime** | 2–30 / -1 | 480p / 720p / 1080p | Reference images / video / audio / document / webpage | [Parameters and examples](/api/videos/wan3-0-video-prime) |
| **HappyHorse 1.0** | 3–15 | 720p / 1080p | Text / images / edit | [Parameters and examples](/api/videos/happyhorse-1-0) |
| **HappyHorse 1.1** | 3–15 | 720p / 1080p | Text / images | [Parameters and examples](/api/videos/happyhorse-1-1) |

Grok models use optional `operation: generate` (default). Base additionally accepts `operation: edit` with exactly one `video_urls` and no generation controls, including `duration`. 1.5 does not edit. Absent and explicit operations have different idempotency fingerprints; keep the original request shape on retry.

Copy the API model ID from the [model catalog](https://api.tokenlio.ai/marketplace). `example/seedance-2.5` is a placeholder: replace it with your model ID, not its display name.

## Endpoints and authentication

Base URL: **`https://api.tokenlio.ai`**. Use your Tokenlio Workspace **model-routing Key**.

| Method | Path relative to the Base URL | Purpose |
| --- | --- | --- |
| `POST` | `/v1/videos/generations` | Create a video task; returns **202** |
| `GET` | `/v1/tasks/{id}` | Get task status and results |
| `GET` | `/v1/tasks/{id}/content` | Obtain a **307** redirect to the private video |
| `GET` | `/v1/tasks/{id}/content?role=last_frame` | Download the last frame when requested and available |

Use `Authorization: Bearer <TOKENLIO_API_KEY>` on all requests and `Content-Type: application/json` on POST requests. Responses are JSON objects. Use the video endpoints below, not Chat/Responses.

## 1. Create

Supply the Key securely through your environment. Replace the placeholder model ID before running.

```bash
BASE_URL='https://api.tokenlio.ai'
curl "$BASE_URL/v1/videos/generations" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"model":"example/seedance-2.5","prompt":"A quiet landscape at sunrise","duration":6,"resolution":"720p"}'
```

Illustrative **202** response; IDs and the model are examples:

```json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "example/seedance-2.5",
  "status": "queued",
  "assets": []
}
```

**202 means your request was accepted.** Save the returned `id` and query it for the final result.

### Task response fields

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Task ID for querying and downloading |
| `model` | string | API model ID used in this request |
| `status` | string | Task status; see the table below |
| `assets` | object[] | Result assets; empty before completion |
| `assets[].role` | string | `video` is the generated video; `last_frame` is the final image, returned only if requested and available |
| `assets[].url` | string | Expiring download link; query the task again for a new link after expiry |
| `assets[].source_url` | string | Optional original asset link, only for Seedance-family API model IDs in successful, fully settled task queries when a URL was recorded. |
| `message` | string | Optional task guidance; if it says not to resubmit, keep querying the original task |
| `error.code` | string | Failure reason, such as `TASK_TIMEOUT` |
| `error.message` | string | Task failure description |

For Seedance-family API model IDs, a successful, fully settled `GET /v1/tasks/{id}` response may include `assets[].source_url` for each recorded original asset URL. Other models and unfinished or failed tasks omit this field. The original link may already be expired or access-limited; its expiry is not checked and the link is not refreshed when querying. Save files promptly; use `assets[].url` if the original link is unavailable. Platform download links and console previews are unchanged. Do not send your Tokenlio API Key to either asset URL.

::: warning Do not automatically retry creation
No extra client request identifier is required. Each POST without one is independent, even with identical parameters. Disable SDK/HTTP automatic retries for creation. If it times out before you receive an ID, check call records before submitting again: another submission may incur another charge.
:::

<details>
<summary>Optional: avoid duplicate creation with Idempotency-Key</summary>

This header is optional. Supply it only once, using 1–128 printable non-whitespace ASCII characters. The same Key, header value and parameters return the original task. Changed parameters return `VIDEO_IDEMPOTENCY_CONFLICT`. Without it, every POST creates an independent task, even with identical parameters.

</details>

## 2. Query

```bash
TASK_ID='dfc68868-d388-4d83-a173-d44e47a8bec7'
curl "$BASE_URL/v1/tasks/$TASK_ID" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY"
```

Poll every 5–15 seconds and increase the interval on read failures. Check progress with GET for the original task; do not POST another creation.

| `status` | Meaning |
| --- | --- |
| `queued` | Waiting for execution |
| `processing` | Video generation is in progress; keep querying |
| `succeeded` | Generation succeeded; use the download links in `assets` |
| `failed` | Task failed or timed out; inspect `error.code` |

Follow any guidance in `message`. If it asks you not to recreate the task, keep querying the same `id` or contact support with that task ID.

Query and download use the API Key that created the task. Keep it valid and never expose it in browser code or logs.

### Success and timeout responses

A successful task provides signed asset links; `last_frame` is included only when requested and available:

```json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "example/seedance-2.5",
  "status": "succeeded",
  "assets": [
    { "role": "video", "url": "https://SIGNED_DOWNLOAD_URL/result.mp4", "source_url": "https://origin.example.com/result.mp4" },
    { "role": "last_frame", "url": "https://SIGNED_DOWNLOAD_URL/frame.png", "source_url": "https://origin.example.com/frame.png" }
  ]
}
```

```json
{
  "id": "dfc68868-d388-4d83-a173-d44e47a8bec7",
  "model": "example/seedance-2.5",
  "status": "failed",
  "assets": [],
  "error": { "code": "TASK_TIMEOUT", "message": "Video task timed out." }
}
```

## 3. Download

When **`status=succeeded`**, download from `assets[].url` without attaching your API Key to that link. Query again when links expire. Alternatively, use these Key-authenticated download endpoints:

```bash
curl --location "$BASE_URL/v1/tasks/$TASK_ID/content" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" -o result.mp4

# Only if return_last_frame=true and the asset is available:
curl --location "$BASE_URL/v1/tasks/$TASK_ID/content?role=last_frame" \
  -H "Authorization: Bearer $TOKENLIO_API_KEY" -o last-frame
```

The content endpoint returns **307**; follow the redirect to download the file. It does not return URL JSON. Save MOV output as a `.mov` file.

::: warning Protect the Key and signed URL
Never use `--location-trusted`. curl removes Authorization on cross-host redirects; custom clients must also strip it before following the storage URL. Do not persist signed URLs or put them in logs. Anyone holding a link can use it until expiry; later permission revocation does not instantly invalidate an already signed link.
:::

## Billing and reference rates

Model pages show USD rates and charging rules, not a task total. Check final charges and currency in console usage records; create/query responses do not include accounting fields. Failed, timed-out or undelivered tasks are not charged. Polling and downloads do not create another generation request.

`expected_pricing_revision` is optional: send it only if you already hold a valid value. A mismatch returns `VIDEO_PRICE_CHANGED`; it does not lock a price. For models that support it, `max_charge_amount` is a non-negative USD decimal string with at most eight fractional digits; an accepted amount above this limit is rejected. Unsupported models reject the field.

Wan supports `duration: -1` for automatic duration. HappyHorse 1.0 also supports `operation: edit`; 1.1 does not. See the model pages for mode-specific fields and input requirements.

## Input URLs and request limits

- Public **HTTPS/443** URLs only. No credentials, fragments, localhost/private addresses or base64. There is no input upload/confirmation API.
- `image_urls` and `image_with_roles` are mutually exclusive. Do not reuse an identical URL within or across input arrays. At most 50 total URL inputs, further limited by each model.
- Input URLs must be directly accessible without redirects. Keep URLs valid and content stable, and prepare materials according to the model's input requirements.
- JSON body ≤64 KiB. Unknown, duplicate and null fields are rejected. Generation requires an explicit integer `duration`; `5.0`, `"5"` and omission are invalid. `-1` is valid only for models that explicitly support automatic duration. Do not append arbitrary query parameters to POST or task-detail requests.
- No `draft`, `draft_task_id`, `tools`, `web_search`, `moderation`, `negative_prompt`, `aspect_ratio` or `audio` aliases. Use the documented platform fields only.

## Errors

Request errors return `{"error":{"message":"…","type":"…"}}`: `type` identifies the error and `message` describes it. A successful query for a failed generation still returns HTTP200; read the task's `status=failed` and `error.code`.

| HTTP / code | Action |
| --- | --- |
| 400 `VIDEO_REQUEST_INVALID` / `VIDEO_ASSET_INVALID` | Check types, model rules, URLs and references |
| 401 `INVALID_API_KEY` | Check the Tokenlio Key, state and IP restrictions |
| 402 `INSUFFICIENT_BALANCE` | Your Workspace has insufficient available funds; top up or check its balance |
| 404 `MEDIA_TASK_NOT_FOUND` | Check the platform task ID and current scope; unauthorized and missing tasks share this response |
| 409 `VIDEO_PRICE_CHANGED` | Review current catalog terms, then decide whether to submit |
| 409 `MEDIA_CONTENT_NOT_READY` | Query the task; do not regenerate |
| 409 `VIDEO_IDEMPOTENCY_CONFLICT` | For optional-header integrations, restore the original parameters |
| 429 `VIDEO_AMOUNT_BUDGET_EXCEEDED` | Check Workspace/member/Key amount budgets |
| 503 `VIDEO_RUNTIME_NOT_READY` / `VIDEO_SERVICE_UNAVAILABLE` | Service temporarily unavailable; try later or contact support. If you have a task ID, only query that task |

Continue with [Seedance 2.0](/api/videos/seedance-2-0), [Seedance 2.0 Fast](/api/videos/seedance-2-0-fast), [Seedance 2.0 Mini](/api/videos/seedance-2-0-mini), [Seedance 2.5](/api/videos/seedance-2-5), [MiniMax H3](/api/videos/minimax-h3) or [MiniMax H3 Max](/api/videos/minimax-h3-max).
