{"id":3256,"library":"reductoai","title":"Reducto Python SDK","description":"The Reducto Python SDK provides a type-safe interface for convenient access to the Reducto REST API from any Python 3.9+ application. It handles authentication, request formatting, and response parsing automatically. The library is currently at version 0.22.0 and has a frequent release cadence, with multiple updates often occurring within a single month.","status":"active","version":"0.22.0","language":"en","source_language":"en","source_url":"https://github.com/reductoai/reducto-python-sdk","tags":["AI","document processing","OCR","API client","PDF","structured data"],"install":[{"cmd":"pip install reductoai","lang":"bash","label":"Install stable version"},{"cmd":"pip install reductoai[aiohttp]","lang":"bash","label":"Install with aiohttp for enhanced async performance"}],"dependencies":[{"reason":"Requires Python 3.9 or higher.","package":"Python","optional":false},{"reason":"Optional dependency for improved concurrency performance with the asynchronous client.","package":"aiohttp","optional":true}],"imports":[{"symbol":"Reducto","correct":"from reducto import Reducto"},{"note":"Use for asynchronous API calls.","symbol":"AsyncReducto","correct":"from reducto import AsyncReducto"},{"note":"Commonly used for specifying local files for upload.","symbol":"Path","correct":"from pathlib import Path"}],"quickstart":{"code":"import os\nfrom pathlib import Path\nfrom reducto import Reducto\n\n# Ensure REDUCTO_API_KEY is set in your environment\n# export REDUCTO_API_KEY=\"your_api_key_here\"\napi_key = os.environ.get('REDUCTO_API_KEY', '')\n\nif not api_key:\n    print(\"Warning: REDUCTO_API_KEY environment variable not set.\")\n    print(\"Please set it to run the quickstart example.\")\n    exit(1)\n\n# Initialize the client\nclient = Reducto(api_key=api_key)\n\n# Create a dummy file for upload example\ndummy_file_path = Path(\"dummy_document.txt\")\ndummy_file_path.write_text(\"This is a dummy document for Reducto.\")\n\ntry:\n    # Upload a document\n    upload_response = client.upload(file=dummy_file_path)\n    print(f\"Uploaded file with ID: {upload_response.file_id}\")\n\n    # Parse the document using the uploaded file_id\n    parse_result = client.parse.run(input=upload_response.file_id)\n    \n    # Access the extracted content (example: print first chunk content)\n    if parse_result.result and parse_result.result.chunks:\n        print(f\"First chunk content: {parse_result.result.chunks[0].content}\")\n    else:\n        print(\"No chunks found in the parsed result.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up the dummy file\n    if dummy_file_path.exists():\n        dummy_file_path.unlink()","lang":"python","description":"This quickstart demonstrates how to initialize the `Reducto` client, upload a local file, and then parse its content. It assumes your Reducto API key is set as an environment variable `REDUCTO_API_KEY`. A dummy file is created for demonstration purposes and then cleaned up."},"warnings":[{"fix":"Update your file upload calls to pass `pathlib.Path('your_file.pdf')`, `open('your_file.pdf', 'rb').read()`, or `('filename.pdf', b'content', 'application/pdf')` instead of just the string path.","message":"The `file` parameter for the `client.upload()` method in `v0.22.0` and later now expects binary file-like objects (e.g., `Path`, `bytes`, or a `(filename, contents, media_type)` tuple) instead of a `str` file path.","severity":"breaking","affected_versions":">=0.22.0"},{"fix":"Re-upload the file if you need to process it again after 24 hours, or implement a mechanism to manage `file_id` lifecycles if persistent storage is required.","message":"Uploaded files to Reducto's servers (identified by `reducto://` URIs) are temporary and expire after 24 hours. Attempting to use an expired `file_id` will result in an error.","severity":"gotcha","affected_versions":"All"},{"fix":"For large files, refer to the Reducto documentation on 'Presigned URL Upload' to handle the upload process correctly.","message":"Direct file uploads via `client.upload()` are limited to 100MB. For files larger than 100MB (up to 5GB), you must use the presigned URL upload method.","severity":"gotcha","affected_versions":"All"},{"fix":"Always set the `REDUCTO_API_KEY` environment variable or explicitly pass `api_key='YOUR_KEY'` when initializing the `Reducto` client.","message":"The SDK automatically reads the API key from the `REDUCTO_API_KEY` environment variable by default. If it's not set, client initialization might fail or requests will be unauthenticated.","severity":"gotcha","affected_versions":"All"},{"fix":"Install with `pip install reductoai[aiohttp]` and then initialize `AsyncReducto` with `http_client=DefaultAioHttpClient()` if `aiohttp` is desired.","message":"While the async client uses `httpx` by default, for improved concurrency performance, it's recommended to install `aiohttp` and configure the client to use it.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}