Every word you type into ChatGPT, every document you upload to Claude, every voice command to Siri β it all goes somewhere.
And somewhere is not a vague concept. It's a specific server. In a specific country. Run by a specific company. Subject to specific laws.
Most people treat AI like a private conversation. It's not. It's a data transmission. And if you're building AI products, you need to understand exactly what that means.
The Data Journey: From Your Keyboard to a GPU
Let's trace what happens when you type "Write me a resignation letter" into an AI app:
Step 1: Your Device
The text sits in your browser or app. So far, so private. If you're using a web app, it's just local JavaScript.
Step 2: TLS Encryption in Transit
Your data travels over HTTPS. TLS 1.3 encrypts it from your device to the server. Nobody in between can read it β not your ISP, not the coffee shop Wi-Fi owner.
Step 3: The API Provider's Servers
Your data hits OpenAI's, Anthropic's, or Google's servers. Here's where it gets interesting:
Provider Data Storage Retention Training Use
| OpenAI API | US-based | 30 days max | No, by default |
|---|---|---|---|
| Azure OpenAI | Your chosen region | Configurable | No, enterprise guarantee |
| Anthropic API | US-based | 30 days | No, by default |
| Google Gemini | Global | 18-36 months | Yes, unless opted out |
Step 4: The Model Processes It
Your data goes into GPU memory. It's processed, the response is generated, and then... what happens to the input?
API vs Consumer: Two Different Privacy Worlds
This is where people get confused. There are TWO completely different privacy regimes:
Consumer Apps (ChatGPT, Claude.ai, Bard)
Data may be used for training
OpenAI and Anthropic use consumer data to improve models
You can opt out, but it's not the default
Free tier users have less control
API Access (What Developers Use)
Data is NOT used for training by default
Enterprise agreements guarantee this
Data retention is limited (usually 30 days for abuse monitoring)
You pay, so you get privacy
The rule: If you're not paying money for API calls, your data is probably helping train next year's model.
π§
PII Detection: Finding the Needles in the Haystack
PII = Personally Identifiable Information. Names, emails, phone numbers, Aadhaar numbers, credit cards, medical records.When you're building AI apps, PII leaks in two directions:
Inbound: User Sends PII to AI
Users paste everything into chat boxes. Resumes, medical reports, legal documents. They don't think about where it goes.
Detection approaches:
python
Option 1: Regex patterns (fast, brittle)
import re
aadhaar_pattern = r'\d{4}\s?\d{4}\s?\d{4}'Option 2: NER models (smarter)
from presidio_analyzer import AnalyzerEngine
analyzer = AnalyzerEngine()
results = analyzer.analyze(text=text, language='en')Option 3: LLM-based detection (most accurate, slowest)
detection_prompt = """Identify all PII in this text. Return as JSON.
Categories: name, email, phone, address, credit_card, ssn, medical_info
"""
Outbound: AI Returns PII from Training Data
Models can memorize training data. Rare, but documented. GPT-4 has been shown to regurgitate exact email addresses and phone numbers from its training set.
Mitigation:
Never train on raw PII
Use differential privacy for fine-tuning
Implement output filters
π
Data Residency: Where Your Data Sleeps
Data residency laws are exploding. Here's what matters:
Regulation Region Key Requirement
GDPR EU Data can leave EU only to "adequate" countries
DPDP Act India Sensitive personal data must stay in India
PIPEDA Canada Consent required for cross-border transfer
China PIPL China Critical data must stay in China
What This Means for AI Apps
If you're serving European users:
Use Azure OpenAI with EU regions
Or use European providers (Mistral, Aleph Alpha)
Sign Data Processing Agreements (DPAs)
If you're serving Indian users:
Store data in Indian data centers
AWS Mumbai, Azure India Central, GCP Mumbai
Get explicit consent before sending to foreign AI providers
Compliance Checklist for AI Builders
Building an AI product that handles user data? Here's your baseline:
- Privacy Policy (Required)
What data you collect
Where it goes (specific providers)
How long you keep it
Whether humans review it
- Data Processing Agreement (DPA)
Required for GDPR, DPDP. Your agreement with OpenAI/Anthropic/etc that specifies:
They act as data processor
You are data controller
Subprocessors are listed
- User Consent Mechanism
Explicit opt-in before AI processing
Granular consent (what specifically are they agreeing to?)
Easy withdrawal
- Data Retention Limits
Delete user data after X days
Delete AI conversation logs
Anonymize analytics data
- Security Measures
Encryption at rest and in transit
Access logging
Regular security audits
Red Flags: When to Worry
π© "We use AI to improve our services" β Vague. Ask specifics.
π© Free AI features with no privacy policy β You're the product.
π© Sending data to multiple providers without disclosure β Compliance violation.
π© Storing full conversation logs indefinitely β Liability nightmare.
π© No DPA with your AI provider β GDPR/DPDP violation waiting to happen.
π¬
Practical Takeaways
Consumer AI apps train on your data β API access does not, by default
PII detection should happen BEFORE sending to AI β Don't rely on the model to be careful
Data residency laws are real β EU data in EU, Indian data in India, or face fines
DPAs are non-negotiable for business use β Get them from every AI provider
Retention limits protect everyone β Set auto-deletion for conversation data
Output can leak training data β Implement post-processing filters for PII
π‘οΈ
What's Next?
Episode 55: Cost Optimization β Caching, model selection, batch processing, prompt compression, and token reduction. Because privacy is important, but so is not burning cash on unnecessary inference.
β Previous
Ep 53: Sandboxing AI Agents
Next β
Ep 55: Cost Optimization
Next: Episode 55 β Cost Optimization
A side project costs βΉ500/month. At scale, βΉ5,00,000/month. The code doesn't change. The usage does. Here's how to fix that.
This is part of a 98-episode series covering AI engineering from tokens to production deployment.