Getting Started
Error Handling
Common errors and how to handle them gracefully
This guide covers the error codes you might encounter when using the Electron Hub API, along with solutions and best practices for handling them.
HTTP Status Codes
The Electron Hub API uses standard HTTP status codes to indicate the success or failure of requests.
Code | Status | Description |
---|---|---|
200 | OK | Request successful |
400 | Bad Request | Invalid request format or parameters |
401 | Unauthorized | Invalid or missing API key |
403 | Forbidden | API key lacks required permissions |
404 | Not Found | Endpoint or resource not found |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server-side error |
503 | Service Unavailable | Service temporarily unavailable |
Common Error Codes
401 - Authentication Errors
Invalid API Key
- Cause: The API key is incorrect, missing, or malformed
- Solution: Verify your API key from the Electron Hub Console
Expired API Key
- Cause: Your API key has been revoked or expired
- Solution: Generate a new API key from your dashboard
429 - Rate Limit Errors
Request Rate Limit
- Cause: Too many requests sent in a short time period
- Solution: Implement exponential backoff and respect rate limits
Token Rate Limit
- Cause: Token usage has exceeded your plan limits
- Solution: Upgrade your plan or wait for the limit to reset
400 - Bad Request Errors
Invalid Model
- Cause: The specified model is not available or misspelled
- Solution: Check the models documentation for available models
Invalid Parameters
- Cause: Request parameters are missing or invalid
- Solution: Verify all required parameters are provided with correct types
Content Policy Violation
- Cause: Input content violates usage policies
- Solution: Review and modify your content to comply with policies
402 - Payment Required
Insufficient Credits
- Cause: Your account has insufficient credits or balance
- Solution: Purchase additional credits or upgrade your plan
Premium Model Access
- Cause: Attempting to use a premium model without subscription
- Solution: Upgrade to a plan that includes premium model access
500 - Server Errors
Internal Server Error
- Cause: Unexpected error on our servers
- Solution: Retry with exponential backoff; contact support if persistent
503 - Service Unavailable
Model Temporarily Unavailable
- Cause: The requested model is temporarily offline
- Solution: Try again later or use an alternative model
Error Response Format
All errors return a consistent JSON format:
Best Practices
Implement Retry Logic
Handle Specific Error Types
Monitor Rate Limits
Check response headers for rate limit information:
Getting Help
If you encounter persistent errors or need assistance:
- Check our status page for service updates
- Join our Discord community for help
- Contact support at [email protected]
- Review our best practices guide for optimization tips