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.2.tar.gz (45.7 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.2-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: redact_proxy-0.1.2.tar.gz
  • Upload date:
  • Size: 45.7 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.2.tar.gz
Algorithm Hash digest
SHA256 6fddc76e349bbad42a808575e2bccdd674a4c5a9243297631bb3aa0efdec6d8f
MD5 1f7ec7b836a99847b9698cd5a4ec6565
BLAKE2b-256 2b53f3d1cf00d2639588ce508c77c5adfcde628ee4b150d80d852525403d2a28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redact_proxy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 38.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d723492de145035462c7c3c26af4238b82baf5d6596722b0b2ae559351e2a834
MD5 d25469a13a8620630e64950c1d8f221a
BLAKE2b-256 0d35b788fca0e458dd7526b2b1956028ee7d01efffd6d63d2b525e451ce9584a

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