Skip to main content

Quickstart

Video generation is always asynchronous. This example uses wan2.6-t2v and an integer duration in seconds.

How Do You Discover Async Media Models and Get Their Schemas?

The discovery flow has two steps. First, retrieve text-to-image or text-to-video models that support the async APIs from the public model catalog. Then use a model’s model_id to retrieve the request Schema for its endpoints.

List Models That Support the Async APIs

The model catalog uses the same data source as Playground. Use type=image_generation for text-to-image models and type=video for text-to-video models. Adding schema_checked=true limits the list to models with a published and reviewed request Schema.
Both requests use the same endpoint. The type filter currently accepts one value, so request each model type separately. The response has the shape {success, message, data}. The following fields in data are relevant to async media integrations.

Get the Request Schema for One Model

Supported fields, enumerations, and numeric ranges can vary by model. Before submitting an image or video request, use the public endpoint below to retrieve the available endpoints and request JSON Schemas for the selected model.
The response has a modality of image or video. Each item in the endpoints array describes one available calling protocol. A model may return both /ai/v1 endpoints and OpenAI-compatible /v1 endpoints. OpenAI-compatible endpoints may not yet support the latest models, so prefer the /ai/v1 endpoints. For async task APIs, select the item whose path is /ai/v1/images/generations or /ai/v1/videos, then use its request.schema. Do not depend on the position of an item in the endpoints array. The following commands extract the request Schema for each async task endpoint.
The endpoint returns 404 model_not_found when the model does not exist or has no discoverable endpoints. It returns 500 endpoints_unavailable when endpoint data is temporarily unavailable.

How Do You Create Video Tasks?

Video requests are always asynchronous and cannot be changed to synchronous waiting with Prefer: wait. The standard protocol uses the integer field duration for the number of seconds:

Standard Video Fields

Structure of an input_references item:
type can be image_url, video_url, or audio_url. Structure of a frame_images item:
frame_type can be first_frame or last_frame.

Media Task Object

Image and video endpoints return the following structure:
Media output item:

Status Reference

Clients can query every 15 seconds until the status becomes completed, failed, or cancelled. The 15-second interval is a client polling recommendation, not a server protocol limit.

How Do You Query Media Tasks?

Get Media Details

Media detail endpoints can return an updated task status, so use the corresponding image or video detail endpoint for media polling.

List Media Tasks

If the creation response is lost, use the corresponding media list to recover the task ID:
Media lists return task snapshots at query time and do not actively update task status.

How Do You Use the Unified Task API?

The unified task API supports the following filters:
Unified task details:
A unified output item for a media task:
For a single-artifact task, request /ai/v1/tasks/{id}/content directly. For a multi-artifact task, request /ai/v1/tasks/{id}/content/{result_id}. Omitting the result ID returns 400 result_id_required.
Unified task list, detail, and content endpoints are isolated by the Bearer token used to create the task. Other API Keys under the same account cannot read the task.

How Do You Download Media Results?

Download Videos

Results may expire, and download limits may apply. An expired result returns 410 artifact_expired; exceeding the download limit returns 429 too_many_downloads.

How Do You Use Webhooks?

Asynchronous images and videos support task-level webhooks:
webhook_url can be up to 512 characters and cannot point to localhost, private networks, or other restricted addresses. When webhook_events_filter is omitted, the platform sends completed, failed, and cancelled. When explicitly provided, the array must not be empty or contain duplicates, and it must be used with webhook_url. When webhook_url is omitted from the request, asynchronous image and video tasks try to use the default callback URL configured for the account. An invalid account default is ignored and does not prevent task creation.

Callback Request

results appears only when results have been archived. Downloads still require a Bearer token.

Retries and Deduplication

The platform uses at-least-once delivery, so the same event may be delivered more than once:
  • HTTP 2xx indicates successful receipt.
  • HTTP 5xx, network errors, or timeouts trigger a retry.
  • HTTP 3xx and 4xx are not retried.
  • Up to 6 delivery attempts are made, with retry intervals of 1, 4, 16, 64, and 256 seconds.
The receiver should store event_id and return 2xx immediately when the same event is received again.
Task-level webhooks do not include a separate signing secret. If signature verification is required, configure an account-level webhook subscription and retain task detail queries as the method for confirming results.

Error Responses and Error Codes

error.tid is the request trace ID. Include it when contacting technical support for troubleshooting.

Complete example

These examples create a task, poll it, and download the MP4 result.