Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_xtract-0.2.0.tar.gz (526.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_xtract-0.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file open_xtract-0.2.0.tar.gz.

File metadata

  • Download URL: open_xtract-0.2.0.tar.gz
  • Upload date:
  • Size: 526.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for open_xtract-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5de6c19100a318fc17bfcf7a0858b860e7e499376b18710638d817b0d8b9c7b9
MD5 e4f50947479702ebdd5e77bae37a3712
BLAKE2b-256 3fd86540d5d606b5276e3909c19e868483db7eafe08214074e606305ca105041

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_xtract-0.2.0.tar.gz:

Publisher: release.yml on Mellow-Artificial-Intelligence/open-xtract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file open_xtract-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: open_xtract-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for open_xtract-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fe9962474c594111a5cb0159c5cff37dd691e88f2dd6b465f5eaefe743be624
MD5 8a365b3d3abe8f396de08f1687fb4a93
BLAKE2b-256 4ed8559e738b44cc4952e518af81cea072b73e0fd1ce72804fec515aeaf32943

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_xtract-0.2.0-py3-none-any.whl:

Publisher: release.yml on Mellow-Artificial-Intelligence/open-xtract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page