Overview
TheAsyncReducto class is the asynchronous client for the Reducto API. It provides the same functionality as the synchronous Reducto client but with full async/await support for better performance in concurrent applications.
Constructor
Parameters
TheAsyncReducto client accepts the same parameters as the synchronous Reducto client:
Your Reducto API key. If not provided, the client will automatically read from the
REDUCTO_API_KEY environment variable.You can obtain your API key from the Reducto dashboard.The API environment to use. Available options:
production- US production environment (https://platform.reducto.ai)eu- EU production environment (https://eu.platform.reducto.ai)au- Australia production environment (https://au.platform.reducto.ai)
Override the base URL for the API. If provided, this takes precedence over the
environment parameter.You can also set this via the REDUCTO_BASE_URL environment variable.Request timeout in seconds. Defaults to 1 hour (3600 seconds).For more granular control, pass an
httpx.Timeout object:Maximum number of retries for failed requests. Defaults to 2.The client automatically retries:
- Connection errors
- 408 Request Timeout
- 409 Conflict
- 429 Rate Limit
- 5xx Server errors
0 to disable retries.Additional headers to include with every request.
Default query parameters to include with every request.
Custom httpx async client instance for advanced use cases. Use this to configure:
- Custom proxies
- Custom transports
- Connection pooling
Basic Usage
Simple Async Example
With Explicit API Key
With EU Environment
Client Methods
upload()
Upload a file directly to Reducto for processing. Returns areducto:// URL that can be used in subsequent API calls.
The file to upload. Can be:
- A
Pathobject - Raw bytes
- A tuple of
(filename, contents, media_type)
Optional file extension hint (e.g., “pdf”, “docx”)
api_version()
Get the current API version.Available Resources
The AsyncReducto client provides access to the same resource namespaces as the synchronous client:client.parse- Document parsing operationsclient.split- Document splitting operationsclient.extract- Data extraction operationsclient.edit- Document editing operationsclient.job- Job management operationsclient.pipeline- Pipeline operationsclient.webhook- Webhook configuration
Using aiohttp
For improved concurrency performance, you can useaiohttp instead of the default httpx client:
Installation
Usage
aiohttp client provides better performance for applications making many concurrent requests.
Advanced Features
Context Manager
Use the async client as a context manager to ensure proper resource cleanup:Per-Request Configuration
Override client settings for individual requests:Concurrent Requests
Process multiple documents concurrently for better performance:Raw Response Access
Access raw HTTP response data including headers:Streaming Response
Stream response data asynchronously for large payloads:Error Handling
The async client raises the same exceptions as the synchronous client:Performance Tips
-
Use aiohttp for high concurrency: If you’re making many concurrent requests, the
aiohttpclient provides better performance than the defaulthttpxclient. - Reuse the client: Create one client instance and reuse it across requests to leverage connection pooling.
-
Use asyncio.gather(): Process multiple documents concurrently using
asyncio.gather()for maximum throughput. - Adjust timeout settings: For long-running operations, increase the timeout to avoid premature failures.
See Also
- Reducto Client - Synchronous version of the client
- Parse Operations - Document parsing methods
- Extract Operations - Data extraction methods