LangChain integration
Mask personal data in LangChain chains and agents
- Prompts built by chains, including retrieved context and memory
- Tool and function-call arguments sent to the model
- Streaming responses, with values restored
- Embeddings calls through the gateway, masked deterministically
LangChain apps pull data from many places into one prompt: user input, retrieved documents, tool results and conversation memory. Any of them can carry a customer's name or an API key.
Because Maskflare works at the HTTP layer, you don't need a LangChain-specific plugin. Set the chat model's base URL to your gateway route and authenticate with a Maskflare key. Everything LangChain sends through that model is masked, and real values come back in the answer.
Set up LangChain with Maskflare
LangChain's chat model classes accept a base URL. Point them at your Maskflare gateway route for the provider and every chain, agent and retriever call is masked.
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o",
base_url="https://YOUR_GATEWAY_HOST/v1/openai",
api_key="mf_live_...", # a Maskflare key
)
llm.invoke("Summarize the ticket from ada@example.com about invoice 4471")What gets masked
- Prompts built by chains, including retrieved context and memory
- Tool and function-call arguments sent to the model
- Streaming responses, with values restored
- Embeddings calls through the gateway, masked deterministically
Good to know
- The same pattern works for other LangChain chat model classes that accept a base URL, such as Anthropic through /v1/anthropic.
- Mask documents before you index them with the SDK's deterministic mode, so your vector store never holds the raw values.
Frequently asked questions
Is there a LangChain package for Maskflare?
You don't need one. LangChain's model classes call the provider over HTTP, so changing the base URL routes them through Maskflare.
Does it work with LangGraph agents?
Yes. Any model call that goes through the configured chat model is masked, whichever agent framework drives it.
What about documents in my vector store?
Mask them with the SDK in deterministic mode before indexing, so the same value always maps to the same token and retrieval still works.
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 →