Docuglean OCR - Python SDK
A unified Python SDK for intelligent document processing using State of the Art AI models.
Features
- 🚀 Easy to Use: Simple, intuitive API with detailed documentation
- 🔍 OCR Capabilities: Extract text from images and scanned documents
- 📊 Structured Data Extraction: Use Pydantic models for type-safe data extraction
- 📄 Multimodal Support: Process PDFs and images with ease
- 🤖 Multiple AI Providers: Support for OpenAI, Mistral, Google Gemini, and Hugging Face
- 🔒 Type Safety: Full Python type hints with Pydantic validation
Installation
pip install docuglean-ocr
Quick Start
OCR Processing
from docuglean import ocr
# Mistral OCR
result = await ocr(
file_path="./document.pdf",
provider="mistral",
model="mistral-ocr-latest",
api_key="your-api-key"
)
# Google Gemini OCR
result = await ocr(
file_path="./document.pdf",
provider="gemini",
model="gemini-2.5-flash",
api_key="your-gemini-api-key",
prompt="Extract all text from this document"
)
# Hugging Face OCR (no API key needed)
result = await ocr(
file_path="https://example.com/image.jpg", # Supports URLs, local files, base64
provider="huggingface",
model="Qwen/Qwen2.5-VL-3B-Instruct",
prompt="Extract all text from this image"
)
Structured Data Extraction
from docuglean import extract
from pydantic import BaseModel
from typing import List
class ReceiptItem(BaseModel):
name: str
price: float
class Receipt(BaseModel):
date: str
total: float
items: List[ReceiptItem]
# Extract structured data with OpenAI
receipt = await extract(
file_path="./receipt.pdf",
provider="openai",
api_key="your-api-key",
response_format=Receipt,
prompt="Extract receipt information"
)
# Extract structured data with Gemini
receipt = await extract(
file_path="./receipt.pdf",
provider="gemini",
api_key="your-gemini-api-key",
response_format=Receipt,
prompt="Extract receipt information including date, total, and all items"
)
Development
Setup
# Install with UV
uv sync
Testing
# Run all tests
uv run pytest tests/ -v
# Run specific test files
uv run pytest tests/test_basic.py -v # Basic tests only
uv run pytest tests/test_ocr.py tests/test_extract.py -v # Mistral tests (requires MISTRAL_API_KEY)
uv run pytest tests/test_openai.py -v # OpenAI tests (requires OPENAI_API_KEY)
# Run with output (shows print statements)
uv run pytest tests/ -v -s
# Run specific test function
uv run pytest tests/test_openai.py::test_openai_extract_unstructured_pdf -v -s
# Set API keys for real testing
export MISTRAL_API_KEY=your_mistral_key_here
export OPENAI_API_KEY=your_openai_key_here
export GEMINI_API_KEY=your_gemini_key_here
uv run pytest tests/ -v -s
Code Quality
# Run linting and type checking
uv run ruff check src/ tests/
# Fix linting issues automatically
uv run ruff check src/ tests/ --fix
# Format code
uv run ruff format src/ tests/
License
Apache 2.0 - see the LICENSE file for details.
Metadata
Release files for docuglean-ocr 1.0.0
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 |
|---|---|---|---|---|
| docuglean_ocr-1.0.0.tar.gz | 93.9 kB | Without provenance | Details for docuglean_ocr-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docuglean_ocr-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for docuglean_ocr-1.0.0-py3-none-any.whl |
Total release size: 111.7 kB
Release files / docuglean_ocr-1.0.0.tar.gz
| Download URL | docuglean_ocr-1.0.0.tar.gz |
|---|---|
| Size | 93.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b65d961c69b3e734151df7747448fe8344ed1dab1eee3288c75b52f3b47b8685
|
|
BLAKE2b-256 checksum How to use checksums |
26b1c74ec358a51ab4da502672b784325050fba76846540fb325c6c2beb13672
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / docuglean_ocr-1.0.0-py3-none-any.whl
| Download URL | docuglean_ocr-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f37e8b4b608406a04cbf7d6fbb62aa5870770a62263caf60775977fe006033a
|
|
BLAKE2b-256 checksum How to use checksums |
d50b5f73d512e2a52c674aaf1f964bbebc8b62c0a5500374fbdeae7d87480524
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for docuglean-ocr 1.0.0
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.