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:Common Errors and Solutions
Authentication Errors
Invalid API Token
Invalid API Token
Error: 401 UnauthorizedResponse: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
Missing API Token
Error: 401 UnauthorizedResponse:Solution: Ensure you’re including the
api-token
header in all requests.Request Errors
Missing Required Parameters
Missing Required Parameters
Error: 400 Bad RequestResponse:Solution: Ensure all required parameters are included in your request. For the
/api/stealthify
endpoint, both prompt
and rephrase
are required.Invalid Parameter Values
Invalid Parameter Values
Error: 400 Bad RequestResponse:Solution: Check that parameter values are in the correct format.
Empty Prompt
Empty Prompt
Error: 400 Bad RequestResponse:Solution: Ensure the prompt parameter contains non-empty content.
Word Limit Exceeded
Word Limit Exceeded
Error: 400 Bad RequestResponse:Solution: Keep your prompt text under 1,500 words.
Not Enough Credits
Not Enough Credits
Error: 402 Payment RequiredResponse:Solution: Purchase additional credits or reduce your usage. For the
/api/stealthify/articles
endpoint, you need at least 50,000 words.Result Not Available
Result Not Available
Error: 403 ForbiddenResponse:Solution: This typically occurs with the articles endpoint when there was an issue generating the article. Try again with a different prompt.
Rate Limit Errors
Too Many Requests
Too Many Requests
Error: 429 Too Many RequestsSolution: Implement request throttling in your application and avoid making too many requests in a short period.
Network and Server Errors
Network Timeout
Network Timeout
Error: 504 Gateway TimeoutSolution: Implement timeout handling and retry logic for network issues.
Server Error
Server Error
Error: 500 Internal Server ErrorSolution: Implement exponential backoff retry logic for server-side 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.