Async Workflow
Understand the asynchronous task pattern used by APIXO
Async Workflow
APIXO uses an asynchronous pattern for all generation tasks. This design handles the reality that AI generation takes time—from a few seconds for images to several minutes for videos.
The Pattern
Step 1: Submit a Task
Send a POST request to create a generation task:
Request:
Response:
The API immediately returns a taskId. The actual generation happens in the background.
Step 2: Get Results
You have two options to receive results:
Option A: Polling (Recommended for Getting Started)
Periodically check the task status:
Response (in progress):
Response (completed):
Option B: Webhooks (Recommended for Production)
Provide a callback_url when submitting:
APIXO will POST the result to your URL when the task completes.
See Webhooks for implementation details.
Task States
| State | Description |
|---|---|
pending | Task queued, waiting to start |
processing | Task is being processed |
success | Task completed successfully |
failed | Task failed (check failMsg) |
Polling Best Practices
- Start with 3-5 second intervals for most tasks
- Use exponential backoff for long-running tasks (videos)
- Set a maximum timeout (e.g., 5 minutes)
- Handle failures gracefully with retry logic
When to Use Each Approach
| Approach | Best For |
|---|---|
| Polling | Simple integrations, client-side apps, testing |
| Webhooks | Production servers, real-time apps, high volume |