Claude AI
OpenAI
Google Gemini
Mistral AI
Ollama

Working with AI?

Error Handling Guide#

This guide covers error handling patterns and best practices when working with the WithoutBG API.

API Error Codes#

Authentication Errors#

Status CodeErrorDescription
401Invalid API KeyThe provided API key is invalid or missing
403Credits ExpiredYour API credits have expired

Request Errors#

Status CodeErrorDescription
402Insufficient CreditNot enough credits available for this request
413File Too LargeFile size exceeds the 10 MB limit
415Unsupported Media TypeFile format not supported
422Validation ErrorRequest validation failed
429Rate Limit ExceededRate limit of 7 requests/minute exceeded

Server Errors#

Status CodeErrorDescription
500Internal Server ErrorServer-side error occurred

Error Response Format#

All API errors return JSON responses with error details:

Error Response Format

{
  "detail": "Error description"
}

Validation Error Example#

Validation Error Response

{
  "detail": [
    {
      "loc": ["body", "image"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Troubleshooting#

Common Issues#

1. Invalid API Key (401)#

  • Verify your API key is correctly set
  • Check for extra spaces or characters
  • Ensure the key hasn't been revoked

2. Rate Limit Exceeded (429)#

  • Wait at least 60 seconds before retrying
  • Use --retry-delay with curl
  • Consider upgrading to a higher tier plan

3. File Size Too Large (413)#

  • Compress images before upload
  • Use image optimization tools
  • Check file size with stat command

4. Validation Errors (422)#

  • Check file format is supported (JPEG, PNG, WebP)
  • Ensure file is not corrupted
  • Verify file extension matches content

Support#

For persistent issues, contact support at: contact@withoutbg.com

Include error details, request timestamps, and your account information for faster resolution.