Skip to main content
The Reducto Python SDK raises specific exceptions for different error conditions. This guide covers all exception types and how to handle them.

Exception Hierarchy


Common Exceptions

APIConnectionError

Raised when the SDK is unable to connect to the API (network issues, timeouts):

AuthenticationError

Raised when API key is missing or invalid (401):

RateLimitError

Raised when rate limit is exceeded (429):

APIStatusError

Base class for all HTTP status errors. Contains status_code and response properties:

APITimeoutError

Raised when a request times out:

Error Code Reference


Generic Error Handling

Handle all errors with a generic catch:

Error Response Details

API errors include detailed information:

Retry Logic

The SDK automatically retries certain errors by default (2 times with exponential backoff):
  • Connection errors (network issues)
  • 408 Request Timeout
  • 409 Conflict
  • 429 Rate Limit
  • =500 Internal Server errors
You can configure retry behavior:

Manual Retry Logic

For more control, implement your own retry logic:

Timeout Handling

Configure timeouts for requests:
Note that requests that time out are retried twice by default.

Long Documents and Timeouts

For large documents like lengthy PDFs or spreadsheets with many sheets, we recommend using the async endpoint. The async endpoint lets you submit a job and poll for results without holding an open connection, which is ideal for documents that take longer to process. If you need to use the sync endpoint with a custom timeout, set max_retries=0 to disable automatic retries. Otherwise, if your request times out while the server is still processing, the SDK will retry and create additional processing jobs for the same document.

Best Practices

Handle Specific Exceptions

Catch specific exception types rather than generic Exception for better error handling.

Log Errors

Log errors with context (job_id, request_id) for debugging.

Retry Transient Errors

The SDK automatically retries transient errors, but you can customize retry behavior.

Provide User Feedback

Show meaningful error messages to users, not raw exceptions.

Check Connection Errors

For APIConnectionError, check e.__cause__ to see the underlying exception.

Handle Rate Limits

Rate limit errors are automatically retried, but you can also handle them manually.

Complete Example


Next Steps