Poll task status
Asynchronous tasks (Submit a task returns data.status=9) must be polled through the status API until they reach a final state.
Request
Polling intervals
status_query.durations in the AI policy is a comma-separated list of milliseconds. Use the intervals in order. Tasks usually reach a final state before the list runs out.
Set a polling deadline that matches how long your use case can wait.
Response
If a task fails, the quota deducted for that task is returned to your account.
A failed query (non-200 HTTP status, timeout, and so on) does not mean the task failed. Keep querying at the durations intervals, and report an error only after several failures in a row.
cURL example
Continuing from the ai, base, and submitted variables in Submit a task. The signature covers the full URL including task_id, and the api function signs each call again.
While the task is in progress, repeat the last command at the millisecond intervals in status_query.durations. When the status is 10, read the result. When it is 2 or 20, check data.msg and stop querying.
Resume a submitted task
Set task_id to the original task ID and send the GET request above to the same status API. Querying an existing task does not consume quota again.