TL;DR: LangChain is the most popular framework for building LLM applications. AI Privacy Gateway integrates as a drop-in proxy — just change the base URL in your ChatOpenAI or ChatAnthropic configuration..
Integration = one config change. No SDK changes needed.
Why Add PII Masking to LangChain?
LangChain is the most popular framework for building LLM applications. AI Privacy Gateway integrates as a drop-in proxy — just change the base URL in your ChatOpenAI or ChatAnthropic configuration.
How It Works
Your App + LangChain
→
Privacy Gateway
(masks PII locally)
→
AI API
(receives clean data)
✓ PII masked before leaving your machine ✓ Zero code changes in your LangChain integration
Benefits
✓
No chain code changes — works with all existing LangChain components
✓
Protects all model providers (OpenAI, Anthropic, DeepSeek, etc.)
✓
Works with streaming, batch, and async LangChain operations
Setup: Connect LangChain to AI Privacy Gateway
Configuration — Change One Line
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o",
base_url="http://localhost:9999/v1", # Route through privacy gateway
api_key="your-api-key"
)
Step-by-Step Setup
- 1 Start the gateway: docker run -d -p 9999:9999 ghcr.io/gunxueqiu6/ai-privacy-gateway:lite
- 2 Change base_url in your ChatOpenAI/ChatAnthropic init to http://localhost:9999/v1
- 3 All PII in prompts and messages is now automatically masked
Start Protecting Your LangChain Data
Deploy AI Privacy Gateway in 30 seconds. Free and open source.
Frequently Asked Questions
Does this work with the latest version of LangChain?
Yes. AI Privacy Gateway works at the HTTP layer as a transparent proxy. It is compatible with any version of LangChain that makes HTTP API calls.
Will this affect my LangChain performance?
The gateway adds less than 1ms per request. The PII detection engine is written in Rust for maximum throughput, so your LangChain application performance will not be noticeably affected.
Can I use this with multiple AI providers through LangChain?
Yes. Route all your AI API calls through the same gateway. It works transparently with any OpenAI-compatible API — just change the base URL.