Quickstart
The native image endpoint is synchronous by default. Set the Boolean fieldasync to true to create a background task. This example uses qwen-image-2.0.
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 Image Tasks?
Synchronous Images
Whenasync is omitted or set to false, the endpoint waits for generation to finish and returns a task object:
GET /ai/v1/images to find the corresponding task.
Asynchronous Images
Whenasync is set to the Boolean value true, the endpoint returns a task object immediately and generation continues in the background:
GET /ai/v1/images/{id} to query an asynchronous image task. After completion, request the content_url from each output item directly. The URL already contains the corresponding image result_id.
async in an image request must be a Boolean. webhook_url and
webhook_events_filter can only be used with async: true.Standard Image Fields
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 Images
After an image task is completed, requestoutput[].content_url from the media task object for each result:
/ai/v1/images/{id}/content/{result_id}. The media task object does not expose result_id separately, so clients can use content_url directly.
When b64_json is not empty, decode that field directly from Base64.
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.