Helium Logo

Error Handling

Understanding HTTP status codes and error responses helps you build robust applications.

HTTP Status Codes

CodeMeaningAction
200SuccessProcess response
400Bad RequestCheck parameters
401UnauthorizedVerify API key
402Payment RequiredCheck billing/credits
404Not FoundCheck IDs
422Validation ErrorFix input format
429Rate LimitedWait and retry
500Server ErrorRetry later

Error Response Format

All error responses follow this format:

{
"detail": "Error message describing the issue"
}

Common Error Scenarios

401 Unauthorized

Your API key is invalid or missing:

{
"detail": "API key not found"
}

Solution: Verify your API key format and ensure it's included in the X-API-Key header.

400 Bad Request

Invalid parameters or missing required fields:

{
"detail": "prompt is required when no files are provided"
}

Solution: Check the endpoint documentation and ensure all required parameters are provided.

429 Rate Limited

You've exceeded your rate limit:

{
"detail": "Rate limit exceeded. Please try again later."
}

Solution: Wait for the rate limit window to reset or upgrade your plan. Check the X-RateLimit-Reset header for the reset time.

Best Practices

  • Always check HTTP status codes before processing responses
  • Implement retry logic for 429 and 500 errors
  • Log error details for debugging
  • Display user-friendly error messages
  • Handle network timeouts gracefully
  • Validate inputs before sending requests