Track and control async jobs
Some models (like image and video generation) run asynchronously: you create a task, get an ID, then query the result with that ID. Use these APIs to query results, check status in batches, and cancel queued tasks.
Call these APIs over HTTP.
Get an API key, then set it as an environment variable.
API description: Query a task's status and result by
API description: Query the status of multiple tasks at once by time range, model, or status.
Rate limit: 20 QPS per Qwen Cloud account.
API description: Cancel a task in
Prerequisites
Call these APIs over HTTP.
Get an API key, then set it as an environment variable.
Query the result of an asynchronous task
API description: Query a task's status and result by task_id.
Rate limit: 20 QPS per Qwen Cloud account.
- You can query all tasks under the Qwen Cloud account that owns the API key, including tasks from any API key under that account. You cannot query tasks from other accounts.
- Completed task data is retained for 24 hours by default (check the specific API reference for the exact duration) before automatic deletion.
Request endpoint
Request parameters
| Parameter passing | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
| Header | Authorization | String | Yes | The API key, in the format Bearer sk-xxx. | Bearer sk-xxx |
| Path | task_id | String | Yes | The task ID to query. | a8532587-xxxx-xxxx-xxxx-0c46b17950d1 |
Response parameters
| Field | Type | Description | Example |
|---|---|---|---|
| request_id | String | The unique ID for this request. | 7574ee8f-xxxx-xxxx-xxxx-11c33ab46e51 |
| output | Object | Contains the result on success or the error code and message on failure. For multi-subtask requests, may include both results and errors. | - |
| output.task_id | String | The queried task ID. | a8532587-xxxx-xxxx-xxxx-0c46b17950d1 |
| output.task_status | String | The task status. A multi-subtask job is marked SUCCEEDED if at least one subtask succeeds. Failed subtasks show their errors in the output. | PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN |
| output.submit_time | String | The time the task was submitted. | 2023-12-20 21:36:31.896 |
| output.scheduled_time | String | The time the task started running. | 2023-12-20 21:36:39.009 |
| output.end_time | String | The time the task ended. | 2023-12-20 21:36:45.913 |
| output.code | String | The error code. Returned only on failure. | - |
| output.message | String | The error message. Returned only on failure. | - |
| output.task_metrics | Object | Subtask status statistics. | { "TOTAL": 4, "SUCCEEDED": 3, "FAILED": 1 } |
| usage | Object | Billing information for this request. Varies by task type. | "usage": {"image_count": 1} |
Request example
If you haven't set the API key as an environment variable, replace
$DASHSCOPE_API_KEY with your actual key. Example: --header "Authorization: Bearer sk-xxx".Response example
Query the status of multiple asynchronous tasks
API description: Query the status of multiple tasks at once by time range, model, or status.
Rate limit: 20 QPS per Qwen Cloud account.
- You can query all tasks under the Qwen Cloud account that owns the API key, including tasks from any API key under that account. You cannot query tasks from other accounts.
- Completed task data is retained for 24 hours by default (check the specific API reference for the exact duration) before automatic deletion.
Request endpoint
Request parameters
| Parameter passing | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
| Header | Authorization | String | Yes | The API key, in the format Bearer sk-xxx. | Bearer sk-xxx |
| Params | task_id | String | No | A specific task ID. If set, only that task is returned. Omit to query multiple tasks. | a8532587-xxxx-xxxx-xxxx-0c46b17950d1 |
| Params | start_time | String | No | Start time (format: YYYYMMDDhhmmss). Defaults to 24 hours before end_time, or the last 24 hours if end_time is also omitted. Range cannot exceed 24 hours. | 20230420193058 represents 19:30:58 on April 20, 2023. |
| Params | end_time | String | No | End time (format: YYYYMMDDhhmmss). Defaults to 24 hours after start_time. Range cannot exceed 24 hours. | 20230420193058 represents 19:30:58 on April 20, 2023. |
| Params | model_name | String | No | The model name. | wan2.6-t2v |
| Params | status | String | No | The task status: PENDING, RUNNING, SUCCEEDED, FAILED, CANCELED, UNKNOWN | |
| Params | page_no | Integer | No | The page number. Default: 1. | - |
| Params | page_size | Integer | No | The number of entries per page. Default: 10. | - |
Response parameters
| Field | Type | Description | Example |
|---|---|---|---|
| request_id | String | The unique ID for this request. | 7574ee8f-xxxx-xxxx-xxxx-11c33ab46e51 |
| data | Array | A list of query results. | See example below |
| data[].api_key_id | String | The API key ID. | See example below |
| data[].caller_parent_id | String | The Qwen Cloud account ID. | See example below |
| data[].caller_uid | String | The Qwen Cloud account UID. | See example below |
| data[].gmt_create | Long | The task creation time in milliseconds since the epoch. | See example below |
| data[].start_time | Long | The task start time in milliseconds since the epoch. | See example below |
| data[].end_time | Long | The task end time in milliseconds since the epoch. | See example below |
| data[].region | String | The region. | See example below |
| data[].request_id | String | The request ID for the task submission. | See example below |
| data[].status | String | The task status: PENDING, RUNNING, SUCCEEDED, FAILED, CANCELED, UNKNOWN | See example below |
| data[].task_id | String | The task ID. | See example below |
| data[].user_api_unique_key | String | A unique index derived from the model's API parameters at submission. | See example below |
| data[].model_name | String | The model name. | See example below |
| page_no | Integer | The current page number. | "page_no": 1 |
| page_size | Integer | The number of entries per page. | "page_size": 10 |
| total_page | Integer | The total number of pages. | "total_page": 4 |
| total | Integer | The total number of entries. | "total": 39 |
| code | String | The error code. Returned only on failure. | "code": "Throttling.RateQuota" |
| message | String | The error message. Returned only on failure. | "message": "Requests rate limit exceeded, please try again later." |
Request example
Response example
Cancel an asynchronous task
API description: Cancel a task in PENDING state. Tasks in other states cannot be canceled.
Rate limit: 20 QPS per Qwen Cloud account.
- You can cancel any task under the Qwen Cloud account that owns the API key, including tasks from any API key under that account. You cannot cancel tasks from other accounts.
Request endpoint
Request parameters
| Parameter passing | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
| Header | Authorization | String | Yes | The API key, in the format Bearer sk-xxx. | Bearer sk-xxx |
| Path | task_id | String | Yes | The task ID to cancel. | a8532587-xxxx-xxxx-xxxx-0c46b17950d1 |
Response parameters
| Field | Type | Description | Example |
|---|---|---|---|
| request_id | String | The unique ID for this request. | 7574ee8f-xxxx-xxxx-xxxx-11c33ab46e51 |
| code | String | The error code. Returned only on failure. | "code": "Throttling.RateQuota" |
| message | String | The error message. Returned only on failure. | "message": "Requests rate limit exceeded, please try again later." |