Skip to main content

HTTP Status Codes

The StealthGPT API uses standard HTTP status codes to indicate the success or failure of requests:
success
The request was successful and the response contains the expected data.
error
The request was malformed or contained invalid parameters.
error
Authentication failed, usually due to an invalid or missing API token.
error
Your request cannot be billed. This can happen when you run out of prepaid words and either (a) you haven’t accepted pay-as-you-go terms (legacy accounts), (b) you don’t have a saved payment method, (c) your account is past due, or (d) billing is temporarily delayed.
error
The requested operation could not be completed (e.g., result not available).
error
You’ve exceeded the rate limits for the API.
error
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

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.
Error: 401 UnauthorizedResponse:
Solution: Ensure you’re including the api-token header in all requests.

Request Errors

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.
Error: 400 Bad RequestResponse:
Solution: Check that parameter values are in the correct format.
Error: 400 Bad RequestResponse:
Solution: Ensure the prompt parameter contains non-empty content.
Error: 400 Bad RequestResponse:
Solution: Keep your prompt text under 3,000 words.
Error: 402 Payment RequiredResponse:
Solution:
  • If you are out of prepaid words, you can:
    • Add prepaid words, or
    • Set up pay-as-you-go billing (saved payment method) and accept the updated pay-as-you-go terms (legacy accounts)
  • For the /api/stealthify/articles endpoint, the request may bill to pay-as-you-go when prepaid is insufficient. If pay-as-you-go is not available, you will receive a 402.
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

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

Error: 504 Gateway TimeoutSolution: Implement timeout handling and retry logic for network issues.
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

  1. Implement Retry Logic: For transient errors (like 429 or 500), implement retry logic with exponential backoff.
  2. Validate Inputs: Validate all parameters before sending requests to avoid 400 errors.
  3. Check Response Status: Always check the HTTP status code before trying to process the response.
  4. Error Logging: Log detailed error information for troubleshooting.
  5. Handle Errors Gracefully: Provide user-friendly error messages in your application rather than exposing raw API errors.