LiteLLM integration
Add PII masking to your LiteLLM proxy with one guardrail
- Every request LiteLLM routes, whichever provider it goes to
- Messages, system prompts and tool-call arguments
- Responses, with masked values restored in post_call mode
- A fail_policy setting so you decide whether a masking failure blocks or passes the request
LiteLLM is a popular way to put one API in front of many model providers. It handles routing, keys, budgets and fallbacks well. Masking personal data is a separate job, and LiteLLM leaves room for it through guardrails.
The Maskflare guardrail plugs into that slot. In pre_call mode it masks the request with your Maskflare rules before LiteLLM forwards it; in post_call mode it restores real values in the response. You keep LiteLLM for routing and get Maskflare's 574 detectors, Exact Data Match and audit trail on top.
Set up LiteLLM with Maskflare
Maskflare runs as a guardrail inside your existing LiteLLM proxy, before and after each model call. Your LiteLLM routing, keys and budgets stay as they are.
# pip install "maskflare[litellm]"
guardrails:
- guardrail_name: maskflare
litellm_params:
guardrail: maskflare.integrations.litellm.MaskflareGuardrail
mode: [pre_call, post_call]
default_on: true
api_key: os.environ/MASKFLARE_API_KEY # a Redaction-purpose key
fail_policy: closedWhat gets masked
- Every request LiteLLM routes, whichever provider it goes to
- Messages, system prompts and tool-call arguments
- Responses, with masked values restored in post_call mode
- A fail_policy setting so you decide whether a masking failure blocks or passes the request
Good to know
- Use a Redaction-purpose Maskflare key. It can mask and unmask but can't call the forwarding routes, so a leaked key can't spend your provider budget.
- fail_policy: closed blocks the request if masking fails. Choose open only if availability matters more than the data in that workload.
- LiteLLM also has a built-in Presidio integration. Maskflare is an alternative detection layer; you can run them side by side on test traffic to compare.
Frequently asked questions
Do I need the Maskflare gateway if I use LiteLLM?
No. The guardrail calls Maskflare's mask and unmask API directly, and LiteLLM keeps routing to your providers.
How do I install it?
Install the Python SDK with the LiteLLM extra (pip install "maskflare[litellm]") and add the guardrail block to your LiteLLM config.
Does it restore values in the response?
Yes, when the guardrail runs in post_call mode as well as pre_call.
How is this different from LiteLLM's Presidio integration?
Presidio uses an NER model plus patterns; Maskflare uses deterministic rules with checksum validation, 47 country packs, 232 credential formats and Exact Data Match, plus a local named-entity layer. Our Presidio comparison covers the trade-offs.
Other integrations
See it on your own data
Try Maskflare free.
Bring your hardest prompts.
28-day free trial or 10,000 requests, whichever comes first. Point one app at the gateway or enroll a few laptops,
and watch what gets masked. Or talk to us first.
- SOC 2 Type II: In progress
- ISO 27001: In progress
- EU hosting by default · on-premises available
- Prompts and files never stored
- Never used to train AI models
- GDPR · nDSG · DPA available
- Trust center →