API Error Codes
This page documents all error codes that the Bleu.js API may return, along with their meanings and suggested solutions.
HTTP Status Codes
Status Code | Error Type | Description | Solution |
---|---|---|---|
400 | Bad Request | Invalid request format or parameters | Check request body and parameters |
401 | Unauthorized | Invalid or missing API key | Verify your API key is correct |
403 | Forbidden | Insufficient permissions | Check your plan and permissions |
404 | Not Found | Resource or endpoint not found | Verify the endpoint URL |
429 | Too Many Requests | Rate limit exceeded | Wait or upgrade your plan |
500 | Internal Server Error | Server-side error | Retry later or contact support |
503 | Service Unavailable | Service temporarily unavailable | Retry later |
API-Specific Error Codes
INVALID_PROMPT
The provided prompt is invalid or too long.
Solution: Check prompt length and content
MODEL_NOT_FOUND
The specified model does not exist or is not available.
Solution: Use a valid model name
QUOTA_EXCEEDED
You have exceeded your usage quota.
Solution: Upgrade your plan or wait for reset
INVALID_PARAMETERS
One or more parameters are invalid.
Solution: Check parameter values and types
CONTENT_FILTERED
The generated content was filtered due to policy violations.
Solution: Modify your prompt to avoid policy violations
Error Response Format
All error responses follow this JSON format:
{ "error": { "code": "INVALID_PROMPT", "message": "The provided prompt is invalid", "details": "Prompt length exceeds maximum allowed length of 4000 characters", "request_id": "req_1234567890abcdef" } }
Error Handling Best Practices
- Always check the HTTP status code first
- Parse the error response for detailed information
- Implement retry logic for transient errors (5xx)
- Log request IDs for debugging
- Handle rate limits with exponential backoff
- Provide user-friendly error messages
Example: Error Handling
// JavaScript example async function handleApiError(response) { if (!response.ok) { const errorData = await response.json(); switch (response.status) { case 401: console.error('Authentication failed:', errorData.error.message); // Handle authentication error break; case 429: const retryAfter = response.headers.get('Retry-After'); console.log(`Rate limited. Retry after ${retryAfter} seconds`); // Implement retry logic break; case 400: console.error('Bad request:', errorData.error.details); // Handle validation error break; default: console.error('API error:', errorData.error); // Handle other errors } throw new Error(errorData.error.message); } return response.json(); }
Getting Help
If you're experiencing persistent errors or need help debugging: