Skip to main content

PaperClean

PaperClean turns poorly photographed or scanned documents into conservative, scanner-like PDFs and images. It uses an image model to clean each page, then requires deterministic content checks and a multimodal reviewer to approve the result. Rejected pages fall back to the original and are recorded in embedded provenance and a JSON report.

PaperClean sends complete document pixels to OpenRouter and the selected model providers. Do not process material whose external transmission is prohibited. --zdr is available only when both selected model endpoints appear in OpenRouter's published zero-data-retention endpoint list; the default image model may not satisfy that requirement. OpenRouter account logging and privacy settings remain the account owner's responsibility.

Install

PaperClean requires Python 3.11 or newer and Tesseract 5.5 or newer. On macOS:

brew install tesseract
uv tool install keyenv
uv tool install paperclean

For a checkout:

uv sync --frozen --all-groups
keyenv authorize OPENROUTER_API_KEY
keyenv set OPENROUTER_API_KEY
keyenv doctor
keyenv run -- uv run paperclean --help

Install additional Tesseract language packs through the platform package manager and select them with --ocr-lang or PAPERCLEAN_OCR_LANG.

Usage

keyenv run -- uv run paperclean document.pdf
keyenv run -- uv run paperclean scans/
keyenv run -- uv run paperclean photo.jpg --max-attempts 3

Supported inputs are PDF, JPEG, and PNG. Directory traversal is recursive and does not follow directory symlinks. A source named document.pdf produces:

document.clean.pdf
document.clean.pdf.report.json

Exit status 0 means every page passed, 2 means one or more original pages were used, and 1 means a fatal/file failure or incomplete batch.

CLI flags override environment variables, which override these defaults:

Environment variable Default
OPENROUTER_BASE_URL https://openrouter.ai/api/v1
PAPERCLEAN_IMAGE_MODEL openai/gpt-image-2
PAPERCLEAN_REVIEW_MODEL openai/gpt-5.6-sol
PAPERCLEAN_MAX_ATTEMPTS 3
PAPERCLEAN_JOBS 1
PAPERCLEAN_OCR_LANG eng
PAPERCLEAN_MAX_COST_USD unset
PAPERCLEAN_ZDR false

OPENROUTER_API_KEY has no default and is required. The valid OpenRouter slug for the requested GPT Image 2 model is openai/gpt-image-2.

PaperClean preserves the original PDF text streams beneath an opaque page overlay. This retains searchable text, but deskewing or perspective correction can make old search-highlight coordinates imperfect. PaperClean rejects encrypted PDFs, unapplied redaction annotations, XFA, JavaScript-driven forms, and calculation-driven forms. Outputs are static sanitized PDFs; interactivity, signatures, active actions, and original attachments are removed.

--max-cost-usd is a soft observed-cost ceiling. When enabled, paid requests are serialized, but one completed request and an ambiguously billed timeout can still exceed the value.

Development

uv sync --frozen --all-groups
uv run ruff check .
uv run mypy -p paperclean
uv run pytest
uv build --no-sources

Live contract and end-to-end tests are never part of the default test run:

keyenv run -- uv run pytest -m live

Release setup

Releases use the repository-local $build-release skill and PyPI Trusted Publishing. Configure the existing paperclean PyPI project with owner tsilva, repository paperclean, workflow release.yml, and environment pypi. Protect the GitHub pypi environment with manual approval.

Metadata

Release files for paperclean 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paperclean 0.1.1
File Size Uploaded Provenance Actions
paperclean-0.1.1.tar.gz 31.8 kB With provenance Details for paperclean-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for paperclean 0.1.1
File Interpreter ABI Platform Actions
paperclean-0.1.1-py3-none-any.whl Python 3 none any Details for paperclean-0.1.1-py3-none-any.whl

Total release size: 65.0 kB

Release files / paperclean-0.1.1.tar.gz

Download URL paperclean-0.1.1.tar.gz
Size 31.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ba4daa04d57db574176c0572b15be0399877cfdae706621ef190cf847ef9895b
BLAKE2b-256 checksum
How to use checksums
f676ed740ed4a1b62bef7dd17478420e4551ddf19de13fb35f58e40fdb5fd3ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 9, 2026.

Transparency log

Release files / paperclean-0.1.1-py3-none-any.whl

Download URL paperclean-0.1.1-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84b74d98dff478f26351bea88e3f6721eacc0462bda83c11d94cc4e8733456e8
BLAKE2b-256 checksum
How to use checksums
17d9e54cd316a1d3755b310582a9c47b21e494fac8792d2e5b41546ede3c600b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 9, 2026.

Transparency log

Security for paperclean 0.1.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for paperclean-0.1.1.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 Aug 9, 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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