error object.
Error response format
| Field | Description |
|---|---|
message | Human-readable description of the error |
type | Error category (e.g., "invalid_request_error", "authentication_error") |
code | Machine-readable error code |
Status codes
| Code | Status | Description |
|---|---|---|
400 | Bad Request | Invalid request body or missing required parameters |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | Key deactivated, insufficient balance, or access denied |
404 | Not Found | Model not found or resource does not exist |
429 | Too Many Requests | Rate limit exceeded — retry after a delay |
500 | Internal Server Error | Server error — retry the request |
502 | Bad Gateway | Provider error — try a different model or retry |
503 | Service Unavailable | Temporary outage — usually resolves in minutes |
Handling specific errors
401 Unauthorized
401 Unauthorized
403 Forbidden
403 Forbidden
Access is denied despite a valid key.
- Insufficient balance: Check your balance with
GET /api/balance. If it’s at or near 0, top up your account. - Deactivated key: Verify the key is active via
GET /api/keys. - Wrong key type: Ensure you’re using a proxy key (
ms-) for inference endpoints and a billing key (mk-) for account management endpoints.
429 Too Many Requests
429 Too Many Requests
You’ve exceeded the request rate limit.Implement exponential backoff: wait before retrying, and double the wait time on each subsequent failure. Start with 1 second.
502 Bad Gateway
502 Bad Gateway
The upstream model provider returned an error.
- This is usually transient — retry the request after a short delay
- If the error persists for a specific model, try a different model with similar capabilities
- Check the
error.messagefield for details from the provider
500 / 503 Server errors
500 / 503 Server errors
A server-side error occurred.
- 500: Retry the request. If it fails consistently, contact support.
- 503: A temporary outage is in progress. Retry after a short wait — these usually resolve within minutes.