·Error Codes
Error Codes
All API errors follow a consistent structure. Check the error.code field for programmatic error handling.
400
missing_fieldsBad RequestRequired fields are missing from the request body.
400
invalid_modelBad RequestThe model field contains an invalid value.
401
unauthorizedUnauthorizedMissing or malformed Authorization header.
401
invalid_keyUnauthorizedThe API key does not exist or has been deleted.
401
key_revokedUnauthorizedThe API key exists but has been revoked.
402
insufficient_creditsPayment RequiredThe account does not have enough credits for this operation.
429
rate_limit_exceededToo Many RequestsThe key has exceeded the 100 requests/minute limit.
500
generation_failedServer ErrorThe image generation failed on the upstream provider.
Handling errors in code
- → Always check HTTP status code first, then
error.codefor specifics - → Retry
500errors with exponential backoff - → For
429errors, respect theRetry-Afterheader - → Never retry
401or402without fixing the underlying issue first