Quickstart
Video generation is always asynchronous. This example useswan2.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’smodel_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. Usetype=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.
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.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.
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 withPrefer: 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
List Media Tasks
If the creation response is lost, use the corresponding media list to recover the task ID:How Do You Use the Unified Task API?
The unified task API supports the following filters:
Unified task details:
output item for a media task:
/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
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
2xxindicates successful receipt. - HTTP
5xx, network errors, or timeouts trigger a retry. - HTTP
3xxand4xxare not retried. - Up to 6 delivery attempts are made, with retry intervals of 1, 4, 16, 64, and 256 seconds.
event_id and return 2xx immediately when the same event is received again.
Error Responses and Error Codes
error.tid is the request trace ID. Include it when contacting technical support for troubleshooting.