Client
Synchronous and asynchronous Docutray Python clients — configuration, auth, and typed methods for convert, identify, and knowledge-base operations.
pip install docutrayuv add docutrayThe main client classes for interacting with the DocuTray API.
Client
Synchronous client for the DocuTray API.
Example:
>>> client = Client(api_key="sk_test_123")
>>> # Convert a document
>>> result = client.convert.run(
... file=Path("invoice.pdf"),
... document_type_code="invoice"
... )
>>> print(result.data)
>>> client.close()
Or using a context manager:
>>> with Client(api_key="sk_test_123") as client:
... result = client.identify.run(file=Path("document.pdf"))
... print(f"Type: {result.document_type.name}")Properties:
-
convert: Document conversion operations. -
document_types: Document type catalog operations. -
identify: Document identification operations. -
knowledge_bases: Knowledge base operations for semantic search. -
steps: Step execution operations.
AsyncClient
Asynchronous client for the DocuTray API.
Example:
>>> async with AsyncClient(api_key="sk_test_123") as client:
... result = await client.convert.run(
... file=Path("invoice.pdf"),
... document_type_code="invoice"
... )
... print(result.data)Properties:
-
convert: Document conversion operations (async). -
document_types: Document type catalog operations (async). -
identify: Document identification operations (async). -
knowledge_bases: Knowledge base operations for semantic search (async). -
steps: Step execution operations (async).
Python SDK
Official Python SDK for the DocuTray API — OCR conversion, document identification, data extraction, and knowledge bases for Python 3.10+.
Exceptions
Error handling in the Docutray Python SDK — the exception hierarchy, API error details, and patterns for catching and recovering from failed requests.