Skip to main content
This guide walks you through integrating Blindfold with an AI application from start to finish. By the end, you’ll have a working chatbot that protects user PII before sending data to OpenAI. Estimated time: 15-20 minutes

What You’ll Build

A privacy-preserving AI chatbot that:
  1. Accepts user input with sensitive data
  2. Detects and tokenizes PII automatically
  3. Sends protected text to OpenAI
  4. Restores original data in the response
  5. Handles errors gracefully

Prerequisites

  • Python 3.8+, Node.js 16+, or Java 11+ installed
  • OpenAI API key (get one here)
  • Blindfold API key (sign up)
Local mode is free forever. All SDKs include local mode with 86 regex-based entity types and all 8 operations — no API key, no signup, no network calls, no data leaves your infrastructure. Just install the SDK and use Blindfold() with no arguments. You only need the Cloud API below if you want NLP-powered detection (names, addresses, organizations) and compliance policies.

Step 1: Install Dependencies

Step 2: Set Up Environment Variables

Create a .env file in your project root:
Never commit .env files to version control. Add .env to your .gitignore file.

Step 3: Create the Privacy-Preserving Chatbot

Create privacy_chatbot.py:
Run it:

Step 4: Understanding the Output

When you run the chatbot, you’ll see:
What happened:
  1. ✅ PII detected and tokenized
  2. ✅ OpenAI never saw real names or emails
  3. ✅ User receives personalized response
  4. ✅ GDPR compliance maintained

Step 5: Add Different Privacy Methods

Masking (Show Last 4 Digits)

Redaction (Permanent Removal)

Step 6: Production Best Practices

Store Mappings Securely

Handle Errors Gracefully

Use Async for Better Performance

Next Steps

Supported Entities

See all 60+ entity types

Policies

Learn about GDPR, HIPAA, PCI DSS policies

Best Practices

Production deployment tips

Examples

More integration examples

Troubleshooting

”Invalid API key” error

  • Check your .env file has the correct API key
  • Verify the API key in your dashboard
  • Ensure load_dotenv() (Python) or dotenv.config() (JavaScript) is called

Entities not detected

  • Try lowering the threshold: score_threshold=0.25
  • Use policy="strict" for maximum detection
  • Check if text is in a supported language

Performance is slow

  • Use async methods for concurrent requests
  • Batch multiple tokenize calls together
  • Consider caching results for duplicate text

Get Help

Support

Questions? Contact hello@blindfold.dev