1
Create a task
Call the generation endpoint and save the returned task ID. Depending on the provider, the field may be named
id, task_id, or taskId.2
Poll the task
Call the matching task endpoint until the task reaches a terminal state. Start with a two-to-five-second interval and use exponential backoff.
3
Read the result
Read the asset URL after the task succeeds. Download or copy the asset promptly because generated URLs may expire.
Recommended polling strategy
Production checklist
- Set a maximum polling duration.
- Retry
429,502,503, and504responses with exponential backoff and jitter. - Retry only the query request. Confirm idempotency before retrying a create request.
- Store the task ID, model ID, and creation time so an interrupted worker can resume.
- Download generated assets promptly instead of treating temporary URLs as permanent storage.