Best Practices
Optimize your APIXO integration for performance and reliability
Best Practices
Follow these recommendations to build robust, efficient integrations.
Choosing Request Mode
| Mode | Best For | Pros | Cons |
|---|---|---|---|
| Async (Polling) | Client apps, simple scripts | Easy to implement | Requires polling logic |
| Callback (Webhooks) | Production servers | Real-time, no polling | Requires public endpoint |
Start with async mode for development, switch to callback for production.
Polling Strategy
For async mode, implement smart polling to balance responsiveness and efficiency.
Recommended Intervals
| Model Type | Initial Wait | Poll Interval | Max Wait |
|---|---|---|---|
| Image (fast) | 5s | 3s | 2 min |
| Image (quality) | 10s | 5s | 3 min |
| Video | 60s | 15s | 10 min |
| Audio | 30s | 10s | 5 min |
Exponential Backoff
Error Handling
Always Handle Failures
Implement Retries
Prompt Engineering
Image Generation Tips
| Do | Don't |
|---|---|
| Be specific: "A golden retriever puppy playing in autumn leaves" | Be vague: "A dog" |
| Include style: "watercolor painting, soft lighting" | Assume defaults |
| Specify composition: "close-up portrait, centered" | Leave composition to chance |
| Use positive descriptions | Use negatives like "no background" |
Effective Prompt Structure
Example:
Resource Management
Download Results Promptly
Store Task IDs
Cost Optimization
Choose the Right Model
| Use Case | Recommended Model | Notes |
|---|---|---|
| Prototyping | Nano Banana | Fast iteration for quick feedback |
| Production quality | Flux-2 Pro | Balanced fidelity and control |
| Premium quality | Midjourney | Strong artistic style |
| Video (short) | Wan 2.5 | Efficient short-form generation |
| Video (cinematic) | Sora 2 | Highest-end video quality |
For current pricing, always refer to the Pricing page.
Batch Similar Requests
If generating multiple variations, use image-to-image mode instead of generating from scratch each time.
Monitor Usage
Security
Protect Your API Key
Validate User Input
Performance
Use Connection Pooling
Parallelize When Possible
Monitoring
Log API Calls
Set Up Alerts
Monitor for:
- High error rates
- Unusual latency
- Cost spikes
- Rate limit hits