Skip to main content
The langchain-blindfold package integrates Blindfold with LangChain, letting you tokenize PII before it reaches your LLM and restore originals in the response. Includes chain-composable Runnables and a DocumentTransformer for RAG pipelines.

Installation

Set your API key:
Get a free API key at app.blindfold.dev.

Quick Start

Protect a LangChain Chain

The LLM only sees <Person_1> and <Email Address_1> — never the real data.

Transform Documents for RAG

Components

blindfold_protect()

Convenience function that returns a paired tokenizer and detokenizer for use in chains:

BlindfoldTokenizer

A LangChain Runnable that tokenizes PII in text and stores the mapping:

BlindfoldDetokenizer

A LangChain Runnable that restores original PII from tokenized text using the paired tokenizer’s mapping:
This is a client-side operation — no API call is made for detokenization.

BlindfoldPIITransformer

A LangChain DocumentTransformer for protecting PII in documents: When pii_method="tokenize", the mapping is stored in doc.metadata["blindfold_mapping"] so you can restore originals later.

Policies

See Policies for details.

PII Methods

The pii_method parameter controls how detected PII is protected (applies to BlindfoldPIITransformer):

Usage Examples

GDPR Compliance with EU Region

HIPAA — Redact PHI in Documents

Protect RAG Pipeline

Detect Specific Entity Types

Data Residency

Use the region parameter to ensure PII is processed in a specific jurisdiction: See Regions for details.

PyPI Package

Install from PyPI

GitHub

Source code and issues

LangChain Docs

LangChain documentation

Cookbook Examples

Working integration examples