Video and image generation are compute-intensive operations that can take anywhere from a few seconds to several minutes to complete. Rather than making you wait for a synchronous HTTP response that could time out, GlobalAI OPC uses an asynchronous task model: you submit a generation request, receive a task ID immediately, and then poll a separate endpoint to check progress until your result is ready.Documentation Index
Fetch the complete documentation index at: https://docs.xingchaoyiqing.com/llms.txt
Use this file to discover all available pages before exploring further.
How Async Tasks Work
Create a task
Send a
POST request to the appropriate generation endpoint (for example, /v1/sora/videos for Sora video generation). The API responds immediately with a task id and an initial status of queued. Keep this ID — you’ll need it to retrieve your result.Poll for status
Send a
GET request to /v1/result/{id} using the task ID you received. Repeat this request on a regular interval (every 30–60 seconds for video, every 2–5 seconds for images) until the status changes from queued or processing to a terminal state.Task Statuses
Every task returned by the API carries astatus field. The following table describes each possible value:
| Status | Description |
|---|---|
queued | The task is waiting in the queue and has not yet started processing. |
processing | The task is actively being generated. Continue polling. |
completed | Generation is complete. The result URL is available in the response. |
failed | Generation failed. Inspect the error field in the response for details. |
cancelled | The task was cancelled before completion. Applies to Seedance 1.5 tasks. |
Polling Best Practices
- Poll every 30–60 seconds for video generation to avoid unnecessary API calls while respecting server load.
- Poll every 2–5 seconds for image generation, which typically completes much faster than video.
- Stop polling immediately when the status is
completed,failed, orcancelled— further polling is wasteful and unnecessary. - Video URLs expire after 24 hours — download your generated video to your own storage as soon as generation completes.
- Image URLs also expire after 24 hours — save generated images to your own storage rather than relying on the temporary URL long-term.
- Do not retry on
failedstatus without reviewing theerrorfield first; the same prompt or parameters may continue to fail.
Code Example: Full Polling Loop
The example below creates a video generation task using the Sora model, then polls in a loop until the task completes or fails.Text chat APIs (OpenAI Chat, Claude Messages, and Gemini Native) are synchronous — they return the model’s response directly in the HTTP response body and do not use the async task pattern described on this page.