Skip to main content

Open Xtract

PyPI version PyPI downloads Python 3.12+ CI License: MIT Coverage Pydantic v2 pydantic-ai

Extract structured data from documents, images, audio, and video using LLMs.

Installation

uv add open-xtract

Usage

from pydantic import BaseModel
from open_xtract import extract

class PdfInfo(BaseModel):
    summary: str
    language: str

result = extract(
    schema=PdfInfo,
    model="google-gla:gemini-3-flash-preview",
    url="https://example.com/document.pdf",
    instructions="return a 2 sentence summary and the primary language of the document",
)
print(result)

Logging

To enable logfire instrumentation for tracing:

from open_xtract import configure_logging

configure_logging()

Error Handling

from open_xtract import (
    extract,
    ExtractionError,
    ModelError,
    SchemaValidationError,
    UrlFetchError,
)

try:
    result = extract(...)
except UrlFetchError as e:
    print(f"Failed to fetch URL: {e}")
except SchemaValidationError as e:
    print(f"Output didn't match schema: {e}")
except ModelError as e:
    print(f"Model API error: {e}")
except ExtractionError as e:
    print(f"Extraction failed: {e}")

Durable Execution

For long-running extractions that need to survive failures, use Temporal-backed durable execution:

uv add open-xtract[temporal]
from open_xtract import extract, stop_temporal

result = extract(
    schema=PdfInfo,
    model="openai:gpt-5.2",
    url="https://example.com/document.pdf",
    instructions="Extract document info",
    durable=True,  # enables Temporal
    temporal_ui=True,  # optional, starts UI on http://localhost:8080
)

# Optional: clean up Docker containers when done
stop_temporal()

When durable=True:

  • Automatically starts Temporal server via Docker (requires Docker to be running)
  • Uses PostgreSQL for persistent workflow state
  • Provides automatic retries and failure recovery
  • Optionally starts Temporal UI for workflow monitoring

Supported Media Types

Type Extensions
Documents .pdf, .doc, .docx, .txt, .html, .csv, .xls, .xlsx
Images .jpg, .jpeg, .png, .gif, .webp, .bmp, .svg
Audio .mp3, .wav, .ogg, .flac, .aac, .m4a
Video .mp4, .mov, .avi, .mkv, .webm, .wmv

Contributing

See CONTRIBUTING.md for development setup and guidelines.

Metadata

Release files for open-xtract 0.2.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 open-xtract 0.2.0
File Size Uploaded
open_xtract-0.2.0.tar.gz 526.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for open-xtract 0.2.0
File Interpreter ABI Platform
open_xtract-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 535.9 kB

Release files / open_xtract-0.2.0.tar.gz

Download URL open_xtract-0.2.0.tar.gz
Size 526.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5de6c19100a318fc17bfcf7a0858b860e7e499376b18710638d817b0d8b9c7b9
BLAKE2b-256 checksum
How to use checksums
3fd86540d5d606b5276e3909c19e868483db7eafe08214074e606305ca105041
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 11, 2026.

Transparency log

Release files / open_xtract-0.2.0-py3-none-any.whl

Download URL open_xtract-0.2.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fe9962474c594111a5cb0159c5cff37dd691e88f2dd6b465f5eaefe743be624
BLAKE2b-256 checksum
How to use checksums
4ed8559e738b44cc4952e518af81cea072b73e0fd1ce72804fec515aeaf32943
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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