Skip to main content

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

Project description

openextract

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 openextract

Usage

from pydantic import BaseModel
from openextract import extract

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

result = extract(
    schema=PdfInfo,
    model="openai-responses:gpt-5.2",
    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 openextract import configure_logging

configure_logging()

Error Handling

from openextract 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}")

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

Changelog

See CHANGELOG.md for release history.

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

openextract-0.3.0.tar.gz (531.5 kB view details)

Uploaded Source

Built Distribution

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

openextract-0.3.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file openextract-0.3.0.tar.gz.

File metadata

  • Download URL: openextract-0.3.0.tar.gz
  • Upload date:
  • Size: 531.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openextract-0.3.0.tar.gz
Algorithm Hash digest
SHA256 01765c8aef3914b59d81ab0f829d28f62a243d8563a2d46894b38bea9de2dd88
MD5 5256438c777fa57993f4b803c5a82e8d
BLAKE2b-256 98fc4d5a920647f1dc6d0ba7d7ebed45547e688adab2fa5a39fa7a6a7997ae5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for openextract-0.3.0.tar.gz:

Publisher: release.yml on Mellow-Artificial-Intelligence/openextract

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

File details

Details for the file openextract-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: openextract-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for openextract-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d56331b70065cba6f311f81ce4b90826be3aa4a0272d607f00491bd8dc3355
MD5 4739536c5eb66dc448ccaad0d637c317
BLAKE2b-256 7aa69266de05a24caa678ffbba4ec1108dc1e96666c77e0909f03299f655b6e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for openextract-0.3.0-py3-none-any.whl:

Publisher: release.yml on Mellow-Artificial-Intelligence/openextract

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