Skip to main content

ocragent

Official Python SDK for OCR Agent — extract structured data from documents using AI.

Installation

pip install ocragent

Quick Start

from ocragent import OcrAgent

client = OcrAgent(api_key="sk_...")

# List your agents
agents = client.agents.list()

# Extract a document
with open("invoice.pdf", "rb") as f:
    result = client.extract(agent_id=agents[0]["id"], file=f)

print(result["data"])
# {"invoice_number": "INV-001", "total_amount": 4250, "due_date": "2025-04-15"}

API

OcrAgent(api_key, ...)

Parameter Default Description
api_key required Your API key (sk_...)
base_url production URL Override the API base URL
max_retries 3 Retries on 429/5xx
timeout 30.0 Request timeout (seconds)

client.agents

client.agents.list()
client.agents.get(agent_id)
client.agents.get_schema(agent_id)
client.agents.update_schema(agent_id, fields=[...])
client.agents.set_status(agent_id, "active" | "paused")
client.agents.delete(agent_id)
client.agents.results(agent_id, period="30d", page=1, limit=20)
client.agents.export_results(agent_id, format="csv")   # returns bytes
client.agents.stats(agent_id)

client.extract

# Single document
client.extract(agent_id, file, file_back=None, callback_url=None)

# Multiple documents
client.extract.batch(agent_id, files=[f1, f2, f3])

# Pre-upload an image
client.extract.upload_image(file)

client.jobs

client.jobs.list(status=None, page=1, limit=20)
client.jobs.get(job_id)
client.jobs.result(job_id)
client.jobs.download(job_id, format="json")  # returns bytes
client.jobs.delete(job_id)

Error Handling

from ocragent.errors import OcrAgentError, AuthError, RateLimitError

try:
    result = client.extract(agent_id="...", file=f)
except AuthError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except OcrAgentError as e:
    print(e.status, e.code, e.message)

Context manager

with OcrAgent(api_key="sk_...") as client:
    agents = client.agents.list()

License

MIT © NxtwaveAI

Metadata

Release files for nxtwaveai-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)

Source distribution for nxtwaveai-ocr 1.0.0
File Size Uploaded
nxtwaveai_ocr-1.0.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nxtwaveai-ocr 1.0.0
File Interpreter ABI Platform
nxtwaveai_ocr-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / nxtwaveai_ocr-1.0.0.tar.gz

Download URL nxtwaveai_ocr-1.0.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
038668b9a6d79d2677965b45c1f372d7e31b5a1c07d1d0593c207f24e05e846b
BLAKE2b-256 checksum
How to use checksums
2737580eb0746ae97654aea204b82f2a7fa0c1ec5a36d027e4d530506dea99fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / nxtwaveai_ocr-1.0.0-py3-none-any.whl

Download URL nxtwaveai_ocr-1.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf1d842edacb80ec8b95f629124af6c37d72b6ca4d1d51cb9018b3bd12d50468
BLAKE2b-256 checksum
How to use checksums
9e0b06df42cd74356bbde61bc444d0d9b807852c8957a08b07664547e6c48f20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page