HTTP Status Codes
| Code | Type | Description |
|---|---|---|
200 | Success | Request completed successfully. |
400 | Bad Request | Invalid parameters or malformed request. |
401 | Unauthorized | Missing or invalid API key. |
403 | Forbidden | Key lacks required permissions or tier access. |
404 | Not Found | Resource or endpoint doesn’t exist. |
429 | Rate Limited | Too many requests. Slow down and retry. |
500 | Server Error | Internal error. Retry with backoff. |
503 | Service Unavailable | Temporary outage. Retry shortly. |
Error Response Format
| Field | Description |
|---|---|
message | Human-readable error description. |
type | Error category (e.g., invalid_request_error, rate_limit_error). |
code | Machine-readable error code for handling. |
param | The specific parameter that caused the error (if applicable). |
Common Errors & Solutions
401: Invalid API Key
401: Invalid API Key
- Verify your key is correct and hasn’t been rotated
- Ensure the
Authorizationheader is formatted asBearer YOUR_API_KEY - Check that your key is active in the Dashboard
429: Rate Limit Exceeded
429: Rate Limit Exceeded
- Implement exponential backoff (see below)
- Check
X-RateLimit-Resetheader for when limits reset - Consider upgrading to a higher tier
400: Context Length Exceeded
400: Context Length Exceeded
- Reduce the length of your prompt or conversation history
- Decrease
max_tokensparameter - Use a model with higher context limits
403: Insufficient Tier
403: Insufficient Tier
Retry Strategy
For transient errors (429, 500, 503), implement exponential backoff:
Python