Reversible proprietary-term pseudonymization guardrail for LiteLLM — mask your codenames/products/schema on the way out, restore them faithfully on the way back.
Project description
lexvault
Reversible proprietary-term pseudonymization for LiteLLM. Mask your codenames, products, customers, and schema on the way out — restore them faithfully on the way back.
lexvault is a LiteLLM proxy plugin that swaps an enterprise's own dictionary terms (codenames, unreleased products, customer names, internal identifiers — not classic PII) for deterministic placeholders on the request path and restores them on the response path. It works across:
- ✅ Non-streaming OpenAI
ModelResponse(/v1/chat/completions) - ✅ Non-streaming Anthropic-native content blocks +
tool_use.input(/v1/messages) - ✅ OpenAI
tool_calls[].function.arguments(request history + output) - ✅ Streaming OpenAI
ModelResponseStream - ✅ Streaming Anthropic-native raw SSE bytes (re-framed + restored)
- ✅
/v1/responsestext (Responses API)
with zero un-restored placeholders reaching the client and zero originals reaching the upstream LLM or logs.
Why?
Classic PII redaction is saturated. The wedge lexvault fills is reversible pseudonymization for an enterprise's proprietary knowledge, with correct round-trip handling across tool calls and streaming — exactly where the leading gateway's own path fails (BerriAI/litellm#22821).
The trust boundary is explicit: your dictionary and the mapping vault never leave your boundary by default. See the concepts docs for the design and threat model.
60-second quickstart
pip install lexvault
Mount the shim next to your LiteLLM config.yaml (LiteLLM's guardrail loader
does a naive split('.') and loads <file>.py from the config dir, so you need
the one-line shim):
# config.yaml
model_list:
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
guardrails:
- guardrail_name: lexvault
litellm_params:
guardrail: lexvault_shim.LexVaultGuardrail # references the mounted shim
mode: [pre_call, post_call]
default_on: true
dictionary_path: dictionary.yaml
org_key: os.environ/LEXVAULT_ORG_KEY
scope: default
# dictionary.yaml
terms:
- term: Project Titan
type: codename
- term: customer_database
type: schema
regex_terms:
- name: Employee ID
pattern: 'EMP-\d{4,6}'
type: id
Run the proxy, and any request mentioning Project Titan reaches the upstream
LLM as something like [LEX-AB12CD34] — and the response is restored before it
reaches your client.
See examples/ for a complete Docker quickstart.
Distribution shape
pip install lexvault # the engine + guardrail
# + lexvault_shim.py mounted next to config.yaml
Documentation
Full docs (concepts, config reference, API reference, integration guide) live at nitishagar.github.io/lexvault.
What's NOT in v0.1
- NER / embeddings / GLiNER / spaCy detection (v0.2)
- Standalone OpenAI-compatible ASGI proxy mode (v0.2)
- Redis vault backend / multi-instance coordination (v0.2)
- OTel/JSONL exhaust recorder,
scanCLI, TS SDK, UI, auth/mTLS (v0.2) - At-rest vault encryption (file-mode
0600protection + documented risk for v0.1) - Tool definition masking in
data["tools"](the model needs verbatim schemas) - Provider-prefixed passthrough routes (
/anthropic/...) bypass all guardrail hooks — documented as unprotected; use unified endpoints (/v1/*)
Prior art
palena-litellm-pseudonymizer and similar one-off pseudonymizers exist, but
none package a focused, tool-call + streaming-correct, enterprise-dictionary
reversible round-trip as a drop-in LiteLLM plugin. LiteLLM's built-in
litellm_content_filter MASK is one-way (no restore), and its Presidio path
has the open round-trip bug above. See the docs for the full landscape.
License
Apache-2.0. Bundles/depends on pyahocorasick (BSD-3-Clause), litellm (MIT), and pydantic (MIT). See NOTICE.
Project details
Release history Release notifications | RSS feed
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 lexvault-0.1.0.tar.gz.
File metadata
- Download URL: lexvault-0.1.0.tar.gz
- Upload date:
- Size: 69.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0659e86c3b107d8bc9516faaffa5d407fee3fc850c69240c57f8443ddc36e39d
|
|
| MD5 |
2ebceeb922164b4f1f09631274c69b8e
|
|
| BLAKE2b-256 |
2c08eec181ce85b32cc44def118b227b9d3088be57ae69a8b0290fbebe0b069f
|
Provenance
The following attestation bundles were made for lexvault-0.1.0.tar.gz:
Publisher:
release.yml on nitishagar/lexvault
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexvault-0.1.0.tar.gz -
Subject digest:
0659e86c3b107d8bc9516faaffa5d407fee3fc850c69240c57f8443ddc36e39d - Sigstore transparency entry: 2172686125
- Sigstore integration time:
-
Permalink:
nitishagar/lexvault@bdfb8c33d313d864b03133584845c600eb9a7f55 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nitishagar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bdfb8c33d313d864b03133584845c600eb9a7f55 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lexvault-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lexvault-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbd1ead11414adfc018d21723072a2655cee654d87ae5e301938cf31790f0940
|
|
| MD5 |
217e9464ef57ad3173aea21814c64e11
|
|
| BLAKE2b-256 |
d1d4f47249cf1622266330046978ad2fd66b4c328157e6811d36a9223b1870fe
|
Provenance
The following attestation bundles were made for lexvault-0.1.0-py3-none-any.whl:
Publisher:
release.yml on nitishagar/lexvault
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexvault-0.1.0-py3-none-any.whl -
Subject digest:
bbd1ead11414adfc018d21723072a2655cee654d87ae5e301938cf31790f0940 - Sigstore transparency entry: 2172686133
- Sigstore integration time:
-
Permalink:
nitishagar/lexvault@bdfb8c33d313d864b03133584845c600eb9a7f55 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nitishagar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bdfb8c33d313d864b03133584845c600eb9a7f55 -
Trigger Event:
push
-
Statement type: