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.

Download files

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

Source Distribution

paperclean-0.1.1.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

paperclean-0.1.1-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file paperclean-0.1.1.tar.gz.

File metadata

  • Download URL: paperclean-0.1.1.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for paperclean-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ba4daa04d57db574176c0572b15be0399877cfdae706621ef190cf847ef9895b
MD5 759ff48009e2e94b40a5a8b0591b5953
BLAKE2b-256 f676ed740ed4a1b62bef7dd17478420e4551ddf19de13fb35f58e40fdb5fd3ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclean-0.1.1.tar.gz:

Publisher: release.yml on tsilva/paperclean

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

File details

Details for the file paperclean-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: paperclean-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for paperclean-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84b74d98dff478f26351bea88e3f6721eacc0462bda83c11d94cc4e8733456e8
MD5 e3ea9ce2444fd16578c1c47f04027aa6
BLAKE2b-256 17d9e54cd316a1d3755b310582a9c47b21e494fac8792d2e5b41546ede3c600b

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperclean-0.1.1-py3-none-any.whl:

Publisher: release.yml on tsilva/paperclean

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