Skip to main content

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexvault-0.1.0.tar.gz (69.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexvault-0.1.0-py3-none-any.whl (45.8 kB view details)

Uploaded Python 3

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

Hashes for lexvault-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0659e86c3b107d8bc9516faaffa5d407fee3fc850c69240c57f8443ddc36e39d
MD5 2ebceeb922164b4f1f09631274c69b8e
BLAKE2b-256 2c08eec181ce85b32cc44def118b227b9d3088be57ae69a8b0290fbebe0b069f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lexvault-0.1.0.tar.gz:

Publisher: release.yml on nitishagar/lexvault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for lexvault-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbd1ead11414adfc018d21723072a2655cee654d87ae5e301938cf31790f0940
MD5 217e9464ef57ad3173aea21814c64e11
BLAKE2b-256 d1d4f47249cf1622266330046978ad2fd66b4c328157e6811d36a9223b1870fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for lexvault-0.1.0-py3-none-any.whl:

Publisher: release.yml on nitishagar/lexvault

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page