TL;DR: The Anthropic SDK for Claude models integrates seamlessly with AI Privacy Gateway. Route your messages through the privacy proxy to ensure no PII reaches Anthropic servers..
Integration = one config change. No SDK changes needed.
Why Add PII Masking to Anthropic SDK?
The Anthropic SDK for Claude models integrates seamlessly with AI Privacy Gateway. Route your messages through the privacy proxy to ensure no PII reaches Anthropic servers.
How It Works
Your App + Anthropic SDK
→
Privacy Gateway
(masks PII locally)
→
AI API
(receives clean data)
✓ PII masked before leaving your machine ✓ Zero code changes in your Anthropic SDK integration
Benefits
✓
Protect proprietary code sent to Claude for analysis
✓
Full Claude Messages API compatibility
✓
Streaming, tool use, and vision all supported
Setup: Connect Anthropic SDK to AI Privacy Gateway
Configuration — Change One Line
import anthropic
client = anthropic.Anthropic(
base_url="http://localhost:9999/v1", # Route through privacy gateway
api_key="your-anthropic-api-key"
)
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "..."}]
)
Step-by-Step Setup
- 1 Deploy gateway: docker run -d -p 9999:9999 ghcr.io/gunxueqiu6/ai-privacy-gateway:lite
- 2 Set base_url in Anthropic() client to http://localhost:9999/v1
- 3 Gateway auto-masks PII, forwards clean prompt to Anthropic API
Start Protecting Your Anthropic SDK Data
Deploy AI Privacy Gateway in 30 seconds. Free and open source.
Frequently Asked Questions
Does this work with the latest version of Anthropic SDK?
Yes. AI Privacy Gateway works at the HTTP layer as a transparent proxy. It is compatible with any version of Anthropic SDK that makes HTTP API calls.
Will this affect my Anthropic SDK performance?
The gateway adds less than 1ms per request. The PII detection engine is written in Rust for maximum throughput, so your Anthropic SDK application performance will not be noticeably affected.
Can I use this with multiple AI providers through Anthropic SDK?
Yes. Route all your AI API calls through the same gateway. It works transparently with any OpenAI-compatible API — just change the base URL.