Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/reductoai/reducto-python-sdk/llms.txt

Use this file to discover all available pages before exploring further.

Retries

Certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors are all retried by default.

Configure Default Retry Settings

You can use the max_retries option to configure or disable retry settings for all requests:
from reducto import Reducto

# Configure the default for all requests:
client = Reducto(
    # default is 2
    max_retries=0,
)

Configure Per-Request Retries

You can also configure retries on a per-request basis using with_options():
from reducto import Reducto

client = Reducto()

# Override retry settings for a specific request:
client.with_options(max_retries=5).parse.run(
    input="https://pdfobject.com/pdf/sample.pdf",
)
Requests that time out are retried twice by default as part of the automatic retry behavior.

Timeouts

By default, requests time out after 1 hour. You can configure this with a timeout option, which accepts a float or an httpx.Timeout object.

Simple Timeout Configuration

Set a simple timeout value in seconds:
from reducto import Reducto

# Configure the default for all requests:
client = Reducto(
    # 20 seconds (default is 1 hour)
    timeout=20.0,
)

Granular Timeout Control

For more granular control over different timeout types:
import httpx
from reducto import Reducto

# More granular control:
client = Reducto(
    timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
)

Per-Request Timeout Override

Override timeout settings for specific requests:
from reducto import Reducto

client = Reducto()

# Override per-request:
client.with_options(timeout=5.0).parse.run(
    input="https://pdfobject.com/pdf/sample.pdf",
)
When a timeout occurs, an APITimeoutError exception is thrown. You can catch this to handle timeout scenarios gracefully in your application.

Timeout Error Handling

import reducto
from reducto import Reducto

client = Reducto()

try:
    response = client.parse.run(
        input="https://pdfobject.com/pdf/sample.pdf",
    )
except reducto.APITimeoutError as e:
    print("Request timed out")
except reducto.APIConnectionError as e:
    print("The server could not be reached")
    print(e.__cause__)  # an underlying Exception, likely raised within httpx.

Build docs developers (and LLMs) love