Error Handling¶
Overview¶
The Claude Code Proxy API returns standard HTTP status codes and structured error responses for different types of failures.
HTTP Status Codes¶
200
- Success400
- Bad Request (invalid parameters)401
- Unauthorized (invalid or missing authentication)403
- Forbidden (insufficient permissions)404
- Not Found (invalid endpoint)429
- Too Many Requests (rate limit exceeded)500
- Internal Server Error503
- Service Unavailable (Claude API unavailable)
Error Response Format¶
All errors return a JSON response with the following structure:
{
"error": {
"type": "invalid_request_error",
"message": "The request was invalid",
"code": "invalid_parameter"
}
}
Common Error Types¶
Authentication Errors¶
{
"error": {
"type": "authentication_error",
"message": "Invalid bearer token",
"code": "invalid_token"
}
}
Rate Limit Errors¶
{
"error": {
"type": "rate_limit_error",
"message": "Too many requests",
"code": "rate_limit_exceeded"
}
}
Invalid Request Errors¶
{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: messages",
"code": "missing_parameter"
}
}
Best Practices¶
- Always check HTTP status codes
- Handle rate limiting with exponential backoff
- Parse error responses for detailed information
- Log errors for debugging
- Implement proper retry logic