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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba4daa04d57db574176c0572b15be0399877cfdae706621ef190cf847ef9895b
|
|
| MD5 |
759ff48009e2e94b40a5a8b0591b5953
|
|
| BLAKE2b-256 |
f676ed740ed4a1b62bef7dd17478420e4551ddf19de13fb35f58e40fdb5fd3ee
|
Provenance
The following attestation bundles were made for paperclean-0.1.1.tar.gz:
Publisher:
release.yml on tsilva/paperclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperclean-0.1.1.tar.gz -
Subject digest:
ba4daa04d57db574176c0572b15be0399877cfdae706621ef190cf847ef9895b - Sigstore transparency entry: 2399750201
- Sigstore integration time:
-
Permalink:
tsilva/paperclean@bb1ad17ff5f37436a5403b090cfbe01b82ccd065 -
Branch / Tag:
refs/tags/paperclean-v0.1.1 - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bb1ad17ff5f37436a5403b090cfbe01b82ccd065 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b74d98dff478f26351bea88e3f6721eacc0462bda83c11d94cc4e8733456e8
|
|
| MD5 |
e3ea9ce2444fd16578c1c47f04027aa6
|
|
| BLAKE2b-256 |
17d9e54cd316a1d3755b310582a9c47b21e494fac8792d2e5b41546ede3c600b
|
Provenance
The following attestation bundles were made for paperclean-0.1.1-py3-none-any.whl:
Publisher:
release.yml on tsilva/paperclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperclean-0.1.1-py3-none-any.whl -
Subject digest:
84b74d98dff478f26351bea88e3f6721eacc0462bda83c11d94cc4e8733456e8 - Sigstore transparency entry: 2399750244
- Sigstore integration time:
-
Permalink:
tsilva/paperclean@bb1ad17ff5f37436a5403b090cfbe01b82ccd065 -
Branch / Tag:
refs/tags/paperclean-v0.1.1 - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bb1ad17ff5f37436a5403b090cfbe01b82ccd065 -
Trigger Event:
push
-
Statement type: