Error Codes
All errors return a JSON body with an error object containing a message, type, and code.
1{
2 "error": {
3 "message": "Invalid API key provided.",
4 "type": "authentication_error",
5 "code": "invalid_api_key"
6 }
7}HTTP Status Codes
400Bad Request
Invalid request body or missing required fields. Check the error message for details.
401Unauthorized
Invalid or missing API key. Ensure your key starts with pk- and is correctly included.
402Payment Required
Subscription inactive or insufficient credits. Upgrade your plan or purchase credits.
403Forbidden
Your plan does not have access to this model or feature.
404Not Found
The requested model or endpoint does not exist.
429Too Many Requests
Rate limit or credit quota exceeded. Implement backoff and retry.
500Internal Server Error
Something went wrong on our end. Try again later.
503Service Unavailable
The model is temporarily unavailable. Try again shortly.
Handling Errors
Always check the HTTP status code and parse the error response body. Implement exponential backoff for 429 and 5xx errors.