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.1.tar.gz (44.3 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.1-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: redact_proxy-0.1.1.tar.gz
  • Upload date:
  • Size: 44.3 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.1.tar.gz
Algorithm Hash digest
SHA256 ca13a7352e6101a44d71d0746093ad5a1009bea96b620b1b3a4524f312936390
MD5 2c14d6eecc0cbfceead2b04b6b88b971
BLAKE2b-256 293a05be233dd73798f2c9efac669b89daec7db769b33b935115ebf34d7f6ea4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: redact_proxy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 297258b72f59b6e14a22425706343029e1d7c380ea1163f452b65dfb2ebceb9b
MD5 8fa4208da0e66550f4773e8fd5daa0f1
BLAKE2b-256 2fe12b31c0690166d86a15e151744fdacb578dc3ae01bec68f2afd63ba62da54

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