Skip to main content

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.

CI PyPI version Python versions License: Apache-2.0 Docs

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/responses text (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, scan CLI, TS SDK, UI, auth/mTLS (v0.2)
  • At-rest vault encryption (file-mode 0600 protection + 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.

Metadata

Release files for lexvault 0.1.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 lexvault 0.1.0
File Size Uploaded Provenance Actions
lexvault-0.1.0.tar.gz 69.4 kB With provenance Details for lexvault-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lexvault 0.1.0
File Interpreter ABI Platform Actions
lexvault-0.1.0-py3-none-any.whl Python 3 none any Details for lexvault-0.1.0-py3-none-any.whl

Total release size: 115.2 kB

Release files / lexvault-0.1.0.tar.gz

Download URL lexvault-0.1.0.tar.gz
Size 69.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0659e86c3b107d8bc9516faaffa5d407fee3fc850c69240c57f8443ddc36e39d
BLAKE2b-256 checksum
How to use checksums
2c08eec181ce85b32cc44def118b227b9d3088be57ae69a8b0290fbebe0b069f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 15, 2026.

Transparency log

Release files / lexvault-0.1.0-py3-none-any.whl

Download URL lexvault-0.1.0-py3-none-any.whl
Size 45.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbd1ead11414adfc018d21723072a2655cee654d87ae5e301938cf31790f0940
BLAKE2b-256 checksum
How to use checksums
d1d4f47249cf1622266330046978ad2fd66b4c328157e6811d36a9223b1870fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 15, 2026.

Transparency log

Security for lexvault 0.1.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 lexvault-0.1.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 Jul 15, 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.1.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