Error Handling
When working with the StealthGPT API, you may encounter errors or issues. This section will help you understand common errors, their causes, and provide guidance on how to troubleshoot and handle them effectively.
Common Errors
1. HTTP 400 Bad Request
This error indicates that the API request was malformed or invalid. This can occur if you've provided incorrect or incomplete parameters, such as an invalid prompt
or an incorrect value for the rephrase
field.
Solution: Double-check your API request and ensure that all required parameters are provided correctly. Verify that your prompt
is a valid string and the rephrase
field is set to either true
or false
.
2. HTTP 401 Unauthorized
An HTTP 401 error indicates that the API token provided in the request header is invalid or missing.
Solution: Ensure that you've included a valid API token in the api-token
header field. Verify that the token is correct and has not expired.
3. HTTP 429 Too Many Requests
This error occurs when you've exceeded the rate limits for the API. The rate limits are in place to ensure fair usage and prevent abuse.
Solution: Implement a rate-limiting strategy or queuing mechanism in your application to manage and distribute your API requests efficiently. You can also consider upgrading your subscription plan to accommodate a higher request volume.
4. HTTP 5xx Server Errors
These errors indicate that there's an issue on the server-side. They are relatively rare but can still occur.
Solution: Wait for a few minutes and try your request again. If the problem persists, contact our support team for assistance.
Troubleshooting Tips
Inspect API responses: When encountering an error, make sure to inspect the API response for additional information. The response may contain error codes, messages, or other details that can help you identify the issue.
Check your code: Ensure that your code is correctly implementing the API request, including headers, parameters, and handling of the response. Refer to the examples provided in the documentation for guidance.
Test with different inputs: If you're unsure whether the issue lies with the API or your application, try making requests with different inputs. This can help you identify if the problem is specific to certain prompts or scenarios.
Monitor API usage: Keep track of your API usage and rate limits to avoid hitting rate limits unexpectedly. Implement rate limiting or queuing mechanisms as needed.
Consult the documentation: Review the API documentation for guidance on proper request formatting, parameters, and other requirements. The documentation is a valuable resource for troubleshooting and understanding API behavior.
Last updated