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.4.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.4.0
File Size Uploaded Provenance Actions
papyrus_sdk-0.4.0.tar.gz 32.7 kB With provenance Details for papyrus_sdk-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 50.8 kB

Release files / papyrus_sdk-0.4.0.tar.gz

Download URL papyrus_sdk-0.4.0.tar.gz
Size 32.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1f87a4114bb6b05559a2c64b0e2e941cf0cce357ffee9ff2b2db0df03e18b95e
BLAKE2b-256 checksum
How to use checksums
0d7e20a76a3cd70ae839f403ad33ccebdf890993baaa99764c4878c2b5243fe5
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 26, 2026.

Transparency log

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

Download URL papyrus_sdk-0.4.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8f72ac807dff6086c64dcdc9b89ca0a7d79c674bd1eb665aa783fe227382f76
BLAKE2b-256 checksum
How to use checksums
0a501accbcded6a47cc708a1355ed879777a2440f27f5047fb507c51a7d74d87
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 26, 2026.

Transparency log

Security for papyrus-sdk 0.4.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.4.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 26, 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