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.6.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.6.0
File Size Uploaded Provenance Actions
papyrus_sdk-0.6.0.tar.gz 34.4 kB With provenance Details for papyrus_sdk-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 54.3 kB

Release files / papyrus_sdk-0.6.0.tar.gz

Download URL papyrus_sdk-0.6.0.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9cefd9b1d3bb2c586b503c1967100c5634b64553e83b5841c86400e88e06517c
BLAKE2b-256 checksum
How to use checksums
bd1190f44013ab7a496aadaa06f704dd43aac95b57825670c4692ba575f1303b
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 Dec 1, 2026.

Transparency log

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

Download URL papyrus_sdk-0.6.0-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec2963768ed9eda832504df489590400ccbbd8ffd7ce18043234dedef14a103c
BLAKE2b-256 checksum
How to use checksums
5473a737f424d2740b13f4d60edafa3031b7dbf13b8959a9906236c1d9392584
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 Dec 1, 2026.

Transparency log

Security for papyrus-sdk 0.6.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.6.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 Dec 1, 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