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.
success
The work runs asynchronously: the async endpoints always answer 202, and /api/stealthify does for a long text that is still running. Poll statusUrl for the result.
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 an API plan or a saved payment method, (c) your account is past due, or (d) billing is temporarily delayed.
error
You’ve exceeded the rate limits for the API.
error
An error occurred on the server. These are typically temporary.
error
The detector could not score the text. The failed /api/stealthify/detect request costs no words. Try again after a short wait.

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:
/api/stealthify/balance answers the same way. The other endpoints word it as API token is missing. You can find it here https://www.stealthgpt.ai/api-dashboard.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, prompt, rephrase and model 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:
    • Subscribe to an API plan; pay-as-you-go turns on with your first payment, or
    • Set up pay-as-you-go billing (saved payment method) and accept the updated pay-as-you-go terms (legacy accounts)

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.