Skip to main content

Papyrus Python SDK

Python client for Papyrus, the self-hosted API that converts documents and web pages into Markdown, chunks and images for LLMs.

pip install papyrus-sdk

Python 3.11 or later. SDK X.Y is made for Papyrus server X.Y.

Usage

from pathlib import Path

from papyrus_sdk import ChunkingOptions, Papyrus

with Papyrus(base_url='http://127.0.0.1:8000', api_key='dev') as client:
    doc = client.markdown(Path('sample.pdf'), chunking=ChunkingOptions(max_tokens=512))
    print(doc.result.text)
    for chunk in doc.chunks or []:
        print(chunk.headings, chunk.tokens)

    page = client.render(Path('sample.pdf'), page=1, format='png')
    page.result.save('page.png')

AsyncPapyrus has the same methods:

import asyncio

from papyrus_sdk import AsyncPapyrus


async def main() -> None:
    async with AsyncPapyrus(base_url='http://127.0.0.1:8000', api_key='dev') as client:
        doc = await client.markdown(source='https://axelered.com')
        print(doc.result.text)


asyncio.run(main())
Method Returns
markdown Markdown of a document or web page, from its text or page images per read_mode (auto by default), chunked with chunking
render One page or image frame at a readable size
thumbnail One page, image or web page fitted into a box
screenshot A web page captured in headless Chromium
inspect Detected format and checks of a document
health, ready Server probes; they do not verify the API key

Responses are typed models with source, options and, except for inspect, result. Read the artifact with result.data (bytes), result.text (Markdown) or result.save(path). With destination the server writes it to storage and only result.uri is set.

Input

Form Meaning
client.markdown(x) A string with :// is a URI, any other string is a local path. Path, bytes and binary files are uploaded
client.markdown(source=x) A URI, sent as is
client.markdown(file=x) An upload: path, Path, bytes or binary file

Use source= for strings that come from users or LLMs. The positional form reads the local file a string names and sends it to the server; source= never reads the local disk.

AsyncPapyrus uploads bytes only, paths and files raise NotImplementedError. filename= names an upload sent as bytes.

Configuration

Argument Default
base_url PAPYRUS_BASE_URL, required
api_key PAPYRUS_API_KEY, no authorization when unset
timeout 310 seconds, also per call. Keep it above the server's limits.deadline
max_retries 2, only for requests the server did not process
http_client An httpx.Client or httpx.AsyncClient, for proxies and private CAs

Errors

from papyrus_sdk import APIError, ConnectionFailed

try:
    client.markdown(source='s3://prod/docs/report.pdf')
except APIError as e:
    print(e.status, e.code, e.detail, e.request_id)
except ConnectionFailed:
    print('server unreachable or timed out')

Branch on code, listed in error codes. Every error derives from PapyrusError.

License

Apache License 2.0. Copyright Axelered D.o.o. and Axelered LLC-Fz.

Metadata

Release files for papyrus-sdk 0.5.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 papyrus-sdk 0.5.0
File Size Uploaded Provenance Actions
papyrus_sdk-0.5.0.tar.gz 32.8 kB With provenance Details for papyrus_sdk-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for papyrus-sdk 0.5.0
File Interpreter ABI Platform Actions
papyrus_sdk-0.5.0-py3-none-any.whl Python 3 none any Details for papyrus_sdk-0.5.0-py3-none-any.whl

Total release size: 51.0 kB

Release files / papyrus_sdk-0.5.0.tar.gz

Download URL papyrus_sdk-0.5.0.tar.gz
Size 32.8 kB
Tags Source
SHA-256 checksum
How to use checksums
147c512c952e688623995dfe7732f1de9aaeda56aabd46a0125e65ecce1973e7
BLAKE2b-256 checksum
How to use checksums
8c7cc413bfc95a5a0c37dc3253d9bfb13867f6604ebffd966570512b98299a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / papyrus_sdk-0.5.0-py3-none-any.whl

Download URL papyrus_sdk-0.5.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47c1377fc7502c19922d03fc7540347908414c5e5a5d23597ceacad33bc95563
BLAKE2b-256 checksum
How to use checksums
3bafc288e432857ce8eb3bf09a498cd47e2932d4341528dafd5cc8db12f570aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for papyrus-sdk 0.5.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for papyrus_sdk-0.5.0.tar.gz

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 Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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