Learn how to handle and resolve common errors you might encounter when using the StealthGPT API
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.
All error responses follow this consistent format:
Some error responses may include additional information:
Invalid API Token
Error: 401 Unauthorized
Response:
Solution: Verify that you’re including the correct API token in the api-token
header. Check your StealthGPT dashboard under the “API Key” tab for the correct token.
Missing API Token
Error: 401 Unauthorized
Response:
Solution: Ensure you’re including the api-token
header in all requests.
Missing Required Parameters
Error: 400 Bad Request
Response:
Solution: Ensure all required parameters are included in your request. For the /api/stealthify
endpoint, both prompt
and rephrase
are required.
Invalid Parameter Values
Error: 400 Bad Request
Response:
Solution: Check that parameter values are in the correct format.
Empty Prompt
Error: 400 Bad Request
Response:
Solution: Ensure the prompt parameter contains non-empty content.
Word Limit Exceeded
Error: 400 Bad Request
Response:
Solution: Keep your prompt text under 1,500 words.
Not Enough Credits
Error: 402 Payment Required
Response:
Solution: Purchase additional credits or reduce your usage. For the /api/stealthify/articles
endpoint, you need at least 50,000 words.
Result Not Available
Error: 403 Forbidden
Response:
Solution: This typically occurs with the articles endpoint when there was an issue generating the article. Try again with a different prompt.
Too Many Requests
Error: 429 Too Many Requests
Solution: Implement request throttling in your application and avoid making too many requests in a short period.
Network Timeout
Error: 504 Gateway Timeout
Solution: Implement timeout handling and retry logic for network issues.
Server Error
Error: 500 Internal Server Error
Solution: Implement exponential backoff retry logic for server-side errors.
Here are comprehensive error handling examples in different programming languages:
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.