Structured Extraction
Typed output from any media.
Extract structured data from documents, images, audio, and video using LLMs and Pydantic schemas.
$ uv add openextract
$ openextract report.pdf \
--schema mypkg:Invoice \
--model xai:grok-4.3
{ "total": 1240.00, "currency": "USD", ... }
Zero Config
One function call, or a reusable session. Bring a schema, media, and a model string.
Multi-Media
Documents, images, audio, and video with smart routing.
Any LLM
OpenAI, Anthropic, Google, Bedrock, xAI, Groq, Mistral, OpenRouter, Ollama, and more via pydantic-ai.
Type Safe
Pydantic schemas ensure validated, typed output every time.
How it works
Schema in, typed data out
Define a BaseModel, call extract(), get validated output.
Define a schema
Describe the shape you want with a Pydantic model.
Point at any media
Documents, images, audio, or video via path, URL, bytes, or a session.
Get typed output
Validated against your schema. No parsing, no regex.
from pydantic import BaseModel
from openextract import extract
class Report(BaseModel):
title: str
findings: list[str]
severity: int
result = extract(
schema=Report,
model="xai:grok-4.3",
input_file="https://example.com/report.pdf",
instructions="Extract findings",
)
What’s new
In v0.15.0
The latest PyPI release: v0.15.0.
form and table
style='form' for labeled forms and receipts; style='table' for line-item docs. PDFs reuse parse-then-window so fields and rows merge across pages. Boxes are still never invented (cite=True for parser-backed citations).
Batch + filters
Directory inputs (--recursive), --out PATH, --pages RANGE, --language TAG, and --schema as a JSON Schema file path.
Citation confidence
Heuristic confidence / match on Citation when cite=True. Optional cite_min_confidence / --cite-min-confidence drops weak cites. Still not a model probability; boxes are never invented.
Also in v0.15.0: on_progress / --progress window callbacks, SchemaValidationError field-path messages, and CLI --cite via Citation.as_dict().
v0.14.0
shipped Citation.as_dict, CLI --cite, and swarm citations.
Documentation
Guides and contracts
Start with the guide. Coding agents should use the agent contract or llms.txt.
Guide
Install, inputs, styles, sessions, batch, errors, and CLI — the how-to.
For agents
Which API to generate, input pitfalls, exceptions, and TestModel fixtures.
API reference
Public functions, sessions, input/result contracts, and common arguments.
CLI contracts
Stdout, stderr, exit codes, retries, styles, and batch partial failures.
Providers
Capability matrix, extras, credentials, and verified vs expected media support.
Troubleshooting
Missing extras, URL fetch, schema failures, retries, and batch API choice.
Works with any media
PDF, DOCX, PNG, JPG, MP3, MP4, and 20+ formats