Handle API errors gracefully
AI Integration MockupError Handling
Learn how to handle errors returned by the API.
Error Format
All errors return a JSON object with an field:
text
json
Error Codes
| Status | Error | Cause |
|---|---|---|
| 401 | Missing API key | No API key provided |
| 401 | Invalid API key | Wrong or expired key |
| 403 | Site is inactive | Site disabled or expired |
| 422 | Invalid request | Malformed request body |
| 429 | Rate limit exceeded | Too many requests |
| 429 | Daily limit exceeded | Daily quota reached |
| 500 | AI service error | Provider unavailable |
Handling Errors
Example Error Handling
javascript
Retry Strategy
For transient errors (500, 429), implement exponential backoff:
javascript