Skip to main content

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.

Hosted API

HostedVault stores the token mappings in the hosted API instead of local SQLite. Pass hosted_api_key="ag_live_..." to SafeOpenAI or SafeAnthropic. API keys are issued at https://ai.artifact-network.org. The default endpoint is https://ai-api.artifact-network.org; pass a different base URL to use your own deployment.

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.5.0

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

Source distribution (sdist)

Source distribution for ag-pii-vault 0.5.0
File Size Uploaded Provenance
ag_pii_vault-0.5.0.tar.gz 9.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ag-pii-vault 0.5.0
File Interpreter ABI Platform
ag_pii_vault-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / ag_pii_vault-0.5.0.tar.gz

Download URL ag_pii_vault-0.5.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cbcde01f75fb690999c63236925c194763d1019c575d2dd8f7daec00b7c7e325
BLAKE2b-256 checksum
How to use checksums
aaa2bbd2853e57f1eb40576a3c9cb49f18078f1b4b6069595f1196dd0748db07
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 25, 2026.

Transparency log

Release files / ag_pii_vault-0.5.0-py3-none-any.whl

Download URL ag_pii_vault-0.5.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6973dadfe34f306aceb206689152cc2d2f9270861d91b691777396d35f6f4c0
BLAKE2b-256 checksum
How to use checksums
6897436be5f9fed872158134cb0ac3d9d9693e9d04c653986fd267e5d870bf26
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 25, 2026.

Transparency log

Security for ag-pii-vault 0.5.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.

Select from 2 files

Attestation for ag_pii_vault-0.5.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 25, 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.5.0 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