Skip to main content

The ngrok for PHI. HIPAA-compliant wrappers for LLM APIs.

Project description

Redact Proxy

The ngrok for PHI.

Drop-in replacements for OpenAI, Anthropic, and Gemini SDKs that automatically redact PHI before sending to the API.

Installation

# Basic (OpenAI + fast detection)
pip install redact-proxy

# With additional providers
pip install redact-proxy[anthropic]
pip install redact-proxy[gemini]

# With enhanced detection
pip install redact-proxy[balanced]   # Adds Presidio NER
pip install redact-proxy[accurate]   # Adds transformer model

# Everything
pip install redact-proxy[all]

Quick Start

OpenAI

# Before (not HIPAA-safe)
from openai import OpenAI

# After (HIPAA-safe) - just change the import!
from redact_proxy import OpenAI

client = OpenAI(phi_detection="fast")

# Same API, PHI automatically redacted
response = client.chat.completions.create(
    model="gpt-4",
    messages=[
        {"role": "user", "content": "Patient John Smith, DOB 01/15/1980, has diabetes"}
    ]
)
# OpenAI receives: "Patient [NAME], DOB [DATE], has diabetes"

Anthropic

from redact_proxy import Anthropic

client = Anthropic(phi_detection="fast")

response = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Patient John Smith has diabetes"}
    ]
)

Gemini

from redact_proxy import Gemini

client = Gemini(phi_detection="fast")

response = client.generate_content(
    "Patient John Smith has diabetes"
)

# Or use chat
chat = client.start_chat()
response = chat.send_message("Patient John Smith has diabetes")

Detection Modes

Mode Speed Method Use Case
fast ~1-5ms Regex patterns Real-time chat, most users
balanced ~20-50ms Patterns + Presidio NER Better name detection
accurate ~100-500ms Patterns + Presidio + Transformer Batch processing, high-risk
# Choose your mode
client = OpenAI(phi_detection="fast")      # Default - fastest
client = OpenAI(phi_detection="balanced")  # Better accuracy
client = OpenAI(phi_detection="accurate")  # Best accuracy

PHI Types Detected

  • Names: Patient, provider, family member names
  • Dates: DOB, visit dates, all date formats
  • Ages: All age formats (65 y/o, 65-year-old, etc.)
  • SSN: Social Security Numbers
  • MRN: Medical Record Numbers
  • Medicare/Medicaid IDs
  • Phone/Fax numbers
  • Email addresses
  • Addresses: Street, city, state, ZIP
  • URLs and IP addresses

Advanced Usage

Custom Placeholder

client = OpenAI(
    phi_detection="fast",
    redact_placeholder="<REDACTED:{phi_type}>"
)
# Output: "Patient <REDACTED:NAME> has diabetes"

Direct Detection

from redact_proxy import PHIDetector

detector = PHIDetector(mode="fast")

# Just detect
findings = detector.detect("Patient John Smith, DOB 01/15/1980")
for f in findings:
    print(f"{f.phi_type}: {f.text} (confidence: {f.confidence})")

# Detect and redact
redacted_text, findings = detector.redact("Patient John Smith, DOB 01/15/1980")
print(redacted_text)  # "Patient [NAME], DOB [DATE]"

Why Redact Proxy?

  1. One-line migration: Just change your import
  2. Zero infrastructure: Works entirely locally
  3. Fast: Pattern-based detection in milliseconds
  4. Configurable: Choose speed vs accuracy tradeoff
  5. Comprehensive: Covers all 18 HIPAA Safe Harbor identifiers

License

MIT

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redact_proxy-0.1.0.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redact_proxy-0.1.0-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file redact_proxy-0.1.0.tar.gz.

File metadata

  • Download URL: redact_proxy-0.1.0.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for redact_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df48ed4c110124a1388b21dd8fa5067d8be3973e17809a158e14f3e2c4743703
MD5 5736d13127ab79b59ba174f0637d1b02
BLAKE2b-256 06f8193ebcb2beb562e4e301d4a31db872ebd6e6ee1cb87eb0307047001c55db

See more details on using hashes here.

File details

Details for the file redact_proxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: redact_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for redact_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 717ee3bd4739bde8f2f520c09bbb7fe281a83a31ae656bf676b721775adcae28
MD5 c3746ee45ff9ff7bdaa17fb816c57842
BLAKE2b-256 a2bcfc5f42ef761bae24e22f4b2ed788b4a2653fbcb6609c9b5a566963ceee36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page