Skip to main content

openparser-sdk

Parse and extract structured data from documents with the OpenParser API.

Install the PyPI distribution openparser-sdk; import the client as openparser.

Documentation · OpenParser

license

Install

pip install openparser-sdk

Use Python 3.10 or newer. Create an API key in the OpenParser dashboard.

Quick Start

import os
from pathlib import Path
from openparser import OpenParserClient

client = OpenParserClient(api_key=os.environ["OPENPARSER_API_KEY"])

result = client.parse.sync(
    {"ocr_model": "paddleocr-vl-1.6", "output_format": "openparser@1"},
    file=Path("invoice.pdf"),
)

print(result.page_count)

Set OPENPARSER_API_KEY to create the client without constructor arguments. Set OPENPARSER_BASE_URL to use a different API origin.

Parse

The API holds synchronous requests for up to 300 seconds. It returns the result when processing finishes or a durable job reference when the wait expires.

# Sync: hold the connection until the result or timeout.
parsed = client.parse.sync(
    {"ocr_model": "paddleocr-vl-1.6"},
    file=Path("document.pdf"),
)

# Async: create a job and poll it later.
accepted = client.parse.async_(
    {"ocr_model": "paddleocr-vl-1.6"},
    file=Path("document.pdf"),
)
job = client.wait_for_job(accepted.id)

# Reuse a file-pool upload instead of inline bytes.
uploaded = client.files.upload(Path("document.pdf"))
parsed = client.parse.sync({"ocr_model": "paddleocr-vl-1.6", "file_id": uploaded.id})

The SDK adds an Idempotency-Key header to every parse and extract request. Pass idempotency_key= when you need to control retries.

Extract

extracted = client.extract.sync(
    {
        "ocr_model": "paddleocr-vl-1.6",
        "llm_model": "openai/gpt-4.1-mini",
        "schema": {
            "type": "object",
            "properties": {"total": {"type": "number"}},
        },
    },
    file=Path("invoice.pdf"),
)

suggested = client.extract.suggest_schema(
    {
        "parse_job_id": "opj_...",
        "hint": "Invoice number, vendor, and total",
    }
)

OpenParserClient is synchronous. Methods named async_ submit durable jobs without waiting for processing to finish.

Jobs

jobs_page = client.jobs.list(status="succeeded", limit=25)
first_job_id = jobs_page.data[0].id
job = client.jobs.get("opj_...")
parse_result = client.jobs.result("opj_...", format="openparser@1")
source_bytes = client.jobs.source("opj_...")

jobs.result() returns parse representations. Extract output is available on the job returned by jobs.get().

Files

uploaded = client.files.upload(Path("contract.pdf"))
metadata = client.files.get(uploaded.id)
content = client.files.download(uploaded.id)
client.files.delete(uploaded.id)

Uploads accept pathlib.Path, a file handle, or {"content": bytes, "filename": str, "mime_type": str?}.

Models

ocr_models = client.models.list_ocr()
llm_models = client.models.list_llm(mode="search", q="claude")
first_ocr_model = ocr_models.data[0]
first_llm_model = llm_models.data[0]

Pipelines

pipeline = client.pipelines.create(
    {
        "name": "invoice-extract",
        "ocr_model": "paddleocr-vl-1.6",
        "llm_model": "anthropic/claude-sonnet-4",
        "schema": {
            "type": "object",
            "properties": {"vendor": {"type": "string"}},
            "required": ["vendor"],
        },
    }
)

listed = client.pipelines.list()
first_pipeline = listed.items[0]
current = client.pipelines.get(pipeline.id)
updated = client.pipelines.update(pipeline.id, {"name": "invoice-v2"})
client.pipelines.delete(pipeline.id)

Errors

Every non-2xx response raises a typed subclass of OpenParserError:

HTTP Class
400 OpenParserValidationError
401 OpenParserAuthError
402 OpenParserPaymentRequiredError
403 OpenParserForbiddenError
404 OpenParserNotFoundError
409 OpenParserConflictError
413 OpenParserLimitExceededError
415 OpenParserUnsupportedMediaError
422 OpenParserUnprocessableError
429 OpenParserRateLimitError
503 OpenParserServiceUnavailableError
504 OpenParserGatewayTimeoutError
5xx OpenParserServerError

Each error exposes the API response through error.envelope: code, message, request_id, and retryable.

Development

After changing the OpenAPI specification, regenerate the client and run its checks:

packages/openparser-sdk-python/scripts/codegen.sh
packages/openparser-sdk-python/scripts/check-codegen.sh
uv run --project packages/openparser-sdk-python pytest

License

Apache-2.0

Download files

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

Source Distribution

openparser_sdk-0.1.0.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

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

openparser_sdk-0.1.0-py3-none-any.whl (170.6 kB view details)

Uploaded Python 3

File details

Details for the file openparser_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: openparser_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openparser_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af6809066f5ca3b3f1b4b9dc8af464f45cb2383f7cf81d0dc7a91cbb5c2d78af
MD5 d3ef9a9131dbc3e774d7e3842da49d32
BLAKE2b-256 bf7caeb729a94e781ad36ca301098c98ace855ed3fdad79d5ceb035a8fecd88d

See more details on using hashes here.

Provenance

The following attestation bundles were made for openparser_sdk-0.1.0.tar.gz:

Publisher: release-openparser-packages.yml on eigenpal/eigenpal

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

File details

Details for the file openparser_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openparser_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 170.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openparser_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52c7e826edc05395435f88c68ca7f226b8eda5e734c6de2c0e7c0faecb97f412
MD5 e6d52b614b7ab1e31075cc4d04c7e939
BLAKE2b-256 8f950515740d2063d6349432b921cbe8798a89d1e2e2619fa31388db28e79dc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for openparser_sdk-0.1.0-py3-none-any.whl:

Publisher: release-openparser-packages.yml on eigenpal/eigenpal

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 Sentry Error logging StatusPage Status page