openextract — open-source Python library

Files in.

Turn documents, images, audio, and video into validated Python objects.

Source · invoice.txt

Total due: 120.00

Quickstart

Your first extraction.

Define an invoice with Pydantic and pass it to extract. The total comes back as a Python Decimal.

Python 3.12+, with OPENAI_API_KEY set.

uv add openextract
invoice.pyPython
from decimal import Decimal
from pydantic import BaseModel
from openextract import extract

class Invoice(BaseModel):
    total: Decimal

invoice = extract(
    Invoice,
    "openai:gpt-6.1-sol",
    "Total due: 120.00",
)
print(invoice.total)
$ python invoice.py120.00