Error Format
All errors follow the OpenAI error format:Error Codes
HTTP Errors
These are returned as the HTTP response status code and in the error body:Mid-Stream Errors
When streaming, errors can occur after the response has started. These appear as a chunk withfinish_reason: "error":
Retry Strategies
Exponential Backoff
For transient errors (429, 500, 502, 503), retry with exponential backoff:When to Retry
Rate Limits
If you hit rate limits frequently:- Add delays between requests
- Reduce the number of concurrent requests
- Contact support if you need higher limits
Debugging
When reporting issues, include:- The error code and message from the response
- The model ID you were using
- The request ID (from the
x-request-idresponse header, if available) - Whether the error was immediate (HTTP error) or mid-stream (finish_reason error)
Related
Chat Completions
Endpoint reference with request and response schemas.
Authentication
Verify your API key is configured correctly.

