Skip to main content Switch to mobile version casepatch 0.6.2 Production data anonymization for AI agent evals: replace identities in PDFs and images, locally or via the CasePatch API
pip install casepatch==0.6.2 Copy PIP instructions
Production data anonymization for AI agent evals. CasePatch replaces the people, accounts, addresses and other identifiers in a case (PDFs, scans and photos, plus the agent's JSON / JSONL / text traces) with realistic fake values, in place, and keeps them consistent across every file of the case.
pip install casepatch # cloud client, no dependencies pip install "casepatch[local]" # local engine: files never leave your machine Two modes, one interface:
mode="auto" (the default, or set CASEPATCH_MODE) uses local when the local engine is installed, otherwise cloud. Local only? Pass mode="local" (CLI: --local): it never uploads and stops with an error if the engine can't run. Auto mode also stops, rather than uploading, when the local engine is installed but can't load. There is no self-hosted HTTP server: on your own servers, use this package or the CLI.
Worked example with downloadable fictional files (statement, dispute letter, JSONL agent trace, expected answers): https://casepatch.com/guides/anonymize-production-data-for-ai-agent-evals.html
Put everything that belongs to one case in one folder: documents (PDF, PNG, JPG, TIFF, WEBP) and traces (.json, .jsonl, .txt: transcripts, tool calls, expected outputs). The folder is ONE case: the same person, account, card or date gets the same replacement in every document and every trace, including JSON fields such as tool-call arguments and expected outputs. JSON keeps its keys, nesting and value types; JSONL keeps one record per line; text keeps its lines.
from casepatch import CasePatch cp = CasePatch(mode="local") # or CasePatch(mode="cloud", api_key="cpk_...") / CASEPATCH_API_KEY results = cp.anonymize_folder("./case", "./anon", report="./anon/changes.jsonl") for r in results: print(r.source, r.ok, r.summary) # {'PERSON': 3, 'CARD_LAST4': 2, ...} print(r.review_line()) # what to check before sharing (never claims zero leaks) casepatch anonymize ./case --out ./anon --local casepatch anonymize ./case --out ./anon --cloud # uses CASEPATCH_API_KEY; the folder is sent as one case casepatch anonymize statement.pdf --out anon.pdf # one file casepatch anonymize ./case --out ./anon --local --keep "Acme Bank" CasePatch(keep=["Acme Bank"]) (or --keep / --keep-file) leaves those terms unchanged in every file of the case.
A file that fails its type/content check (for example invalid JSON, with the line number) is reported and left out; the other files still run as one case. If the case itself cannot run, every file reports the error: a case is never split into files with separate identity maps. Traces must be UTF-8, at most 5 MB (JSONL: 20,000 records).
Each Result has output, summary, changes (original -> replacement, keep this private) and what the engine's report says about it: engine_version, is_synthetic (always False: values CasePatch did not detect stay original), source_sent_to_cloud, likely_misses (structural signs a value may still be original), verification and gate. review_required is False only when verification ran and found nothing to check; values CasePatch never detected are not counted, so review every output before you share it. This is not a compliance certification or a formal de-identification determination.
HTTPS uses this Python's trusted certificates; on a python.org macOS Python without them it uses the system roots. Behind a proxy or with a custom CA, set SSL_CERT_FILE.
The cloud mode wraps the REST API described at https://casepatch.com/api/v1/openapi.json: POST /api/v1/anonymize (one document, one trace, or a ZIP of a whole case), GET /api/v1/jobs/{id}, GET /api/v1/jobs/{id}/result, DELETE /api/v1/jobs/{id}, GET /api/v1/usage. Authenticate with Authorization: Bearer .
Support: support@casepatch.com
Author/Maintainer: CasePatch
Apache-2.0 View SPDX License List
ner docs docs-gliner docs-llm fixtures local local-hq studio
anonymization pii redaction evals ai-agents synthetic-data pdf
Development Status 3 - Alpha
Intended Audience Developers
Programming Language Python :: 3
Release files for casepatch 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 6.6 MB
Release files / casepatch-0.6.2.tar.gz
Release files / casepatch-0.6.2-py3-none-any.whl
Security for casepatch 0.6.2
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.
None of the files in this release were uploaded with provenance metadata.
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
Nov 24, 2026 2 release files No provenance
Nov 20, 2026 2 release files No provenance
Nov 19, 2026 2 release files No provenance
Nov 17, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




