Unsiloed Python SDK
The official Python SDK for Unsiloed - a powerful document processing platform that enables you to parse, extract, classify, and split documents with ease.
Features
- Parse: Extract structured content from documents (PDFs, images, etc.)
- Extract: Extract specific data using JSON schemas with citations
- Classify: Classify documents into predefined categories
- Split: Split document pages based on categories
- Both Sync & Async: Choose the client that fits your application
Installation
pip install unsiloed-sdk
Quick Start
Synchronous Usage
Perfect for scripts, notebooks, and traditional Python applications:
from unsiloed_sdk import UnsiloedClient
with UnsiloedClient(api_key="your-api-key-here") as client:
result = client.parse_and_wait(file="document.pdf")
print(f"Total chunks: {result.total_chunks}")
Async Usage
Perfect for FastAPI apps and concurrent processing:
import asyncio
from unsiloed_sdk import AsyncUnsiloedClient
async def main():
async with AsyncUnsiloedClient(api_key="your-api-key-here") as client:
result = await client.parse_and_wait(file="document.pdf")
print(f"Total chunks: {result.total_chunks}")
asyncio.run(main())
Authentication
Get your API key from the Unsiloed Dashboard.
from unsiloed_sdk import UnsiloedClient
client = UnsiloedClient(api_key="your-api-key-here")
Set as environment variable:
export UNSILOED_API_KEY="your-api-key"
import os
from unsiloed_sdk import UnsiloedClient
client = UnsiloedClient(api_key=os.getenv("UNSILOED_API_KEY"))
Usage Examples
Parse Documents
Extract structured content from any document:
from unsiloed_sdk import UnsiloedClient
# Initialize the client
with UnsiloedClient(api_key="your-api-key") as client:
# Parse a document and wait for results
result = client.parse_and_wait(file="document.pdf")
# Access the parsed content
print(f"Total chunks: {result.total_chunks}")
# Get the embed content
for chunk in result.chunks:
print(f"\n--- {chunk['embed'][:100]} ---")
Extract Data with Schema
Define exactly what data you need using JSON schema. The property names are the fields you want to extract, and descriptions specify what type of data to look for:
from unsiloed_sdk import UnsiloedClient
schema = {
"type": "object",
"properties": {
"invoice_number": {
"type": "string",
"description": "Invoice number from the document"
},
"date": {
"type": "string",
"description": "Invoice date"
},
"total_amount": {
"type": "number",
"description": "Total amount"
}
},
"required": ["invoice_number", "date", "total_amount"],
"additionalProperties": False
}
with UnsiloedClient(api_key="your-api-key") as client:
result = client.extract_and_wait(
file="invoice.pdf",
schema=schema
)
# Results include confidence scores
print(f"Invoice #: {result.result['invoice_number']['value']}")
print(f"Confidence: {result.result['invoice_number']['score']}")
print(f"Total: ${result.result['total_amount']['value']}")
Advanced Example - Extracting shareholding data:
from unsiloed_sdk import UnsiloedClient
schema = {
"type": "object",
"properties": {
"Individuals": {
"type": "string",
"description": "Percentage Holding"
},
"LIC of India": {
"type": "string",
"description": "No of Shares Held"
},
"United bank of india": {
"type": "string",
"description": "No of shares held by United bank of india"
}
},
"required": ["Individuals", "LIC of India", "United bank of india"],
"additionalProperties": False
}
with UnsiloedClient(api_key="your-api-key") as client:
result = client.extract_and_wait(
file="shareholding.pdf",
schema=schema
)
for field, data in result.result.items():
print(f"{field}: {data['value']} (confidence: {data['score']:.2%})")
Classify Documents
Automatically categorize your documents:
from unsiloed_sdk import UnsiloedClient
with UnsiloedClient(api_key="your-api-key") as client:
result = client.classify_and_wait(
file="document.pdf",
categories=["Invoice", "Receipt", "Contract", "Letter"]
)
print(f"Type: {result.result['classification']}")
print(f"Confidence: {result.result['confidence']}")
Split Documents
Separate multi-document files by page type:
from unsiloed_sdk import UnsiloedClient, Category
categories = [
Category(name="Cover Page", description="Document cover or title page"),
Category(name="Main Content", description="Primary document content and body text")
]
with UnsiloedClient(api_key="your-api-key") as client:
result = client.split_and_wait(
file="report.pdf",
categories=categories
)
# Check if split was successful
if result.result['success']:
print(f"✓ {result.result['message']}")
# Access the generated split files
for file_info in result.result['files']:
print(f"File: {file_info['name']}")
print(f" Confidence: {file_info['confidence_score']:.2%}")
print(f" Download: {file_info['full_path']}")
else:
print(f"Split failed: {result.result['message']}")
Async Examples
Concurrent Processing
Process multiple documents at once with async:
import asyncio
from unsiloed_sdk import AsyncUnsiloedClient
async def main():
async with AsyncUnsiloedClient(api_key="your-api-key") as client:
# Process 3 documents concurrently
results = await asyncio.gather(
client.parse_and_wait(file="doc1.pdf"),
client.parse_and_wait(file="doc2.pdf"),
client.parse_and_wait(file="doc3.pdf"),
)
for i, result in enumerate(results, 1):
print(f"Document {i}: {result.total_chunks} chunks")
asyncio.run(main())
Async Extract
import asyncio
from unsiloed_sdk import AsyncUnsiloedClient
async def main():
schema = {
"type": "object",
"properties": {
"company": {
"type": "string",
"description": "Company name"
},
"amount": {
"type": "number",
"description": "Total amount"
}
},
"required": ["company", "amount"],
"additionalProperties": False
}
async with AsyncUnsiloedClient(api_key="your-api-key") as client:
result = await client.extract_and_wait(
file="invoice.pdf",
schema=schema
)
# Access extracted values with confidence scores
print(f"Company: {result.result['company']['value']}")
print(f"Amount: {result.result['amount']['value']}")
asyncio.run(main())
Error Handling
from unsiloed_sdk import (
UnsiloedClient,
AuthenticationError,
QuotaExceededError,
InvalidRequestError
)
try:
with UnsiloedClient(api_key="your-api-key") as client:
result = client.parse_and_wait(file="document.pdf")
except AuthenticationError:
print("Invalid API key")
except QuotaExceededError as e:
print(f"Quota exceeded. Remaining: {e.response_data}")
except InvalidRequestError as e:
print(f"Invalid request: {e.message}")
Which Client Should I Use?
| Use Case | Client | Example |
|---|---|---|
| Scripts, notebooks | UnsiloedClient |
client.parse_and_wait(file="doc.pdf") |
| Flask, Django | UnsiloedClient |
client.extract_and_wait(file="invoice.pdf", schema=schema) |
| FastAPI, async apps | AsyncUnsiloedClient |
await client.classify_and_wait(file="doc.pdf", categories=[...]) |
| Concurrent processing | AsyncUnsiloedClient |
await asyncio.gather(...) |
API Methods
Both UnsiloedClient (sync) and AsyncUnsiloedClient (async) have the same methods:
Parse:
parse()- Start parse jobget_parse_result(job_id)- Check job statusparse_and_wait()- Parse and wait for completion ⭐ Most common
Extract:
extract()- Start extract jobget_extract_result(job_id)- Check job statusextract_and_wait()- Extract and wait for completion ⭐ Most common
Classify:
classify()- Start classify jobget_classify_result(job_id)- Check job statusclassify_and_wait()- Classify and wait for completion ⭐ Most common
Split:
split()- Start split jobget_split_result(job_id)- Check job statussplit_and_wait()- Split and wait for completion ⭐ Most common
Tip: Use the
*_and_wait()methods for simpler code. They handle polling automatically.
Examples
Check the examples/ directory for complete working examples:
parse_example.py- Document parsingextract_example.py- Data extractionclassify_example.py- Document classificationsplit_example.py- Document splitting
Support
- Documentation: https://docs.unsiloed.ai/
- API Reference: https://docs.unsiloed.ai/api-reference
- Support Email: support@unsiloed.com
- Issues: https://github.com/unsiloed/unsiloed-sdk-python/issues
License
MIT License - see LICENSE file for details.
Metadata
Release files for unsiloed-sdk 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| unsiloed_sdk-0.1.7.tar.gz | 103.2 kB | Without provenance | Details for unsiloed_sdk-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unsiloed_sdk-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for unsiloed_sdk-0.1.7-py3-none-any.whl |
Total release size: 117.3 kB
Release files / unsiloed_sdk-0.1.7.tar.gz
| Download URL | unsiloed_sdk-0.1.7.tar.gz |
|---|---|
| Size | 103.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94d66ce8802ccdd815f0f7172309ce4eed25186873511377aa66cb9150cd0ea8
|
|
BLAKE2b-256 checksum How to use checksums |
f897f39b08141c058e131c9dd9ddaf55f21b731a30a26df738ab43d2226ea08f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Release files / unsiloed_sdk-0.1.7-py3-none-any.whl
| Download URL | unsiloed_sdk-0.1.7-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b96e26381f70d39b05f8636c80d31ee664217f51084c39f3a6ae556692372531
|
|
BLAKE2b-256 checksum How to use checksums |
c528ba65722340cda50f234d4845045ff81e90ef03860551376b9fbfced771f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Security for unsiloed-sdk 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.