Error Codes
API Reference
HTTP Status Codes
| Code | Meaning | Action |
|---|---|---|
200 | Success | Request processed successfully |
400 | Bad Request | Check your request body — invalid JSON, missing model or messages |
401 | Unauthorized | Invalid or missing API key. Check your Authorization header |
402 | Insufficient Balance | Top up your account in the dashboard |
403 | Forbidden | Your key doesn't have access to this model or your account is suspended |
429 | Rate Limited | You've exceeded your plan's rate limit. Retry after the Retry-After header value |
500 | Internal Error | Something went wrong on our end. Barq will automatically retry with fallback models |
503 | Service Unavailable | Barq is temporarily overloaded. Retry with exponential backoff |
Error Response Format
{
"error": {
"message": "Insufficient balance. Required: $0.015, Available: $0.003",
"type": "insufficient_balance",
"code": 402
}
}
Retry Strategy
For 429 and 5xx errors, use exponential backoff:
- 1st retry: wait 1 second
- 2nd retry: wait 2 seconds
- 3rd retry: wait 4 seconds
- Max retries: 3