ag-pii-vault
PII tokenization for LLM pipelines.
Detects personal data (names, emails, phone numbers and other Presidio entities), replaces it with deterministic HMAC tokens before text is sent to an LLM, and restores it in the response. Token mappings live in a local SQLite vault or in the hosted vault.
Install
pip install "ag-pii-vault[all]"
npm install ag-pii-vault
Extras: openai, anthropic, all. Detection uses the spaCy model en_core_web_lg: python -m spacy download en_core_web_lg.
Usage
from ag_pii_vault import Detector, LocalVault, Tokenizer
detector = Detector()
tokenizer = Tokenizer(vault=LocalVault(path=":memory:"), key="my-hmac-secret")
text = "Contact John Smith at john@acme.com"
safe = tokenizer.tokenize(text, detector.analyze(text))
print(safe) # PII replaced by tokens
print(tokenizer.dehydrate(safe)) # original text restored
Output:
Contact PERSON_353fcd26 at EMAIL_9abc0eb1
Contact John Smith at john@acme.com
SafeOpenAI and SafeAnthropic wrap the official clients: messages are tokenized on the way out and restored on the way back.
The TypeScript package ag-pii-vault is a port of the core classes.
Self-hosted API
HostedVault stores the token mappings in a self-run ag-platform deployment instead of local SQLite. Pass hosted_api_key and hosted_vault_url to SafeOpenAI or SafeAnthropic (TypeScript: new HostedVault({ apiKey, vaultUrl })). There is no default endpoint.
Development
cd packages/python && pip install -e ".[all]" && pytest
cd packages/typescript && npm ci && npm test
License
MIT, Copyright (c) 2026 Adnan Ghribi.
Metadata
Release files for ag-pii-vault 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ag_pii_vault-0.6.0.tar.gz | 9.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ag_pii_vault-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / ag_pii_vault-0.6.0.tar.gz
| Download URL | ag_pii_vault-0.6.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd8e4ffc5fed9fbc595fafef57d92b49480f32cfdc65166d60c71f50dd551e32
|
|
BLAKE2b-256 checksum How to use checksums |
1e631854b91b02846e98d8a050f9ee0b056b938f400fce22cec681193cff7b73
|
| 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 Oct 26, 2026.
Transparency logRelease files / ag_pii_vault-0.6.0-py3-none-any.whl
| Download URL | ag_pii_vault-0.6.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce9821e990e23607731df0b20e5e43ecc2d8fb2a87b58c8924ff114718ff630c
|
|
BLAKE2b-256 checksum How to use checksums |
d25b2bcc1c4b9fe81031a1f294c83ddbddc69e1c39ab9acfc22fa82a2f3d72dd
|
| 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 Oct 26, 2026.
Transparency logSecurity for ag-pii-vault 0.6.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ag_pii_vault-0.6.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 Oct 26, 2026.
Transparency logA 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.