200 OK status.
Error response format
All HTTP errors follow the OpenAI error format:The HTTP status code, or a string error identifier for mid-stream errors.
A human-readable description of what went wrong.
Additional context such as provider details or internal request IDs.
HTTP error codes
| Code | Name | Cause | What to do |
|---|---|---|---|
400 | Bad Request | Malformed JSON, missing required fields | Check your request body and required parameters |
401 | Unauthorized | Invalid or missing API key | Verify the Authorization header contains a valid key |
402 | Payment Required | Insufficient account credits | Add credits at app.cline.bot |
403 | Forbidden | Key does not have access to this resource | Check key permissions |
404 | Not Found | Invalid endpoint path or model ID | Verify the URL and model ID format (provider/model-name) |
429 | Too Many Requests | Rate limit exceeded | Wait and retry with exponential backoff |
500 | Internal Server Error | Server-side issue | Retry after a short delay |
502 | Bad Gateway | Upstream provider error | Retry after a short delay |
503 | Service Unavailable | Service temporarily down | Retry after a short delay |
Mid-stream errors
When streaming, errors can occur after the HTTP response has started. Because the connection is already open with a200 OK status, these errors appear as a chunk inside the stream with finish_reason: "error":
| Code | Meaning |
|---|---|
context_length_exceeded | Input tokens exceed the model’s context window |
content_filter | Content was blocked by a safety filter |
rate_limit | Rate limit hit during generation |
server_error | Upstream provider failed during generation |
Retry strategies
When to retry
| Error | Retry? | Strategy |
|---|---|---|
400 Bad Request | No | Fix the request |
401 Unauthorized | No | Fix your API key |
402 Payment Required | No | Add credits |
429 Too Many Requests | Yes | Exponential backoff starting at 1s |
500 Internal Server Error | Yes | Retry once after 1s |
502 Bad Gateway | Yes | Retry up to 3 times with backoff |
503 Service Unavailable | Yes | Retry up to 3 times with backoff |
Mid-stream error | Depends | Retry the full request for transient errors |
Exponential backoff
For transient errors (429, 500, 502, 503), retry with exponential backoff to avoid overwhelming the API:
Rate limits
If you hit429 errors frequently:
- Add delays between requests
- Reduce the number of concurrent requests
- Contact support if you need a higher rate limit
Debugging
When reporting an issue, include the following to help diagnose it faster:- The error code and message from the response body
- The model ID you were using
- The request ID from the
x-request-idresponse header (if present) - Whether the error was immediate (HTTP error) or mid-stream (
finish_reason: "error")
Authentication
Verify your API key is set up correctly.
Chat completions
Review request parameters and response format.