Error Handling
Learn how to handle and resolve common errors you might encounter when using the StealthGPT API
HTTP Status Codes
The StealthGPT API uses standard HTTP status codes to indicate the success or failure of requests:
The request was successful and the response contains the expected data.
The request was malformed or contained invalid parameters.
Authentication failed, usually due to an invalid or missing API token.
You don’t have enough credits in your account to perform this action.
The requested operation could not be completed (e.g., result not available).
You’ve exceeded the rate limits for the API.
An error occurred on the server. These are typically temporary.
Error Response Format
All error responses follow this consistent format:
Some error responses may include additional information:
Common Errors and Solutions
Authentication Errors
Request Errors
Rate Limit Errors
Network and Server Errors
Language-Specific Error Handling Examples
Here are comprehensive error handling examples in different programming languages:
Best Practices for Error Handling
-
Implement Retry Logic: For transient errors (like 429 or 500), implement retry logic with exponential backoff.
-
Validate Inputs: Validate all parameters before sending requests to avoid 400 errors.
-
Check Response Status: Always check the HTTP status code before trying to process the response.
-
Error Logging: Log detailed error information for troubleshooting.
-
Handle Errors Gracefully: Provide user-friendly error messages in your application rather than exposing raw API errors.