A lightweight, zero-dependency output sanitizer for secrets, API keys, and PII.
Project description
llm-redacted
Stop leaking secrets. One function call.
A lightweight, zero-dependency Python library that sanitizes secrets, API keys, PII, and sensitive data from text. Designed for LLM output pipelines.
Installation
pip install llm-redacted
Quick Start
from llm_redacted import sanitize_output
text = "My API key is sk-12345678901234567890"
clean = sanitize_output(text)
print(clean)
# Output: My API key is [OPENAI_KEY]
Features
- 20 Built-in Detectors: OpenAI, AWS, GitHub, Stripe, JWT, GCP, Slack, Twilio, Azure, Discord, PEM, Email, Phone, IPv4, SSN, Credit Cards, Env Vars, Local Paths, Connection Strings, Bearer Tokens.
- Zero Dependencies: Pure Python stdlib.
- Reversible Redaction: Keep a mapping of original secrets to restore them later.
- Streaming Support: Sanitize LLM streams token-by-token.
- Extensible: Add custom regex detectors easily.
Advanced Usage
Reversible Redaction
from llm_redacted import sanitize_output, restore_output
result = sanitize_output("Email admin@test.com", detailed=True)
print(result.cleaned) # Email [EMAIL_1]
restored = restore_output(result.cleaned, result.mapping)
print(restored) # Email admin@test.com
Streaming
from llm_redacted import StreamingSanitizer
sanitizer = StreamingSanitizer()
# feed tokens one by one
safe_token = sanitizer.feed("sk-")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
llm_redacted-0.2.2.tar.gz
(11.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_redacted-0.2.2.tar.gz.
File metadata
- Download URL: llm_redacted-0.2.2.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9377a68487aa0326a6df80985b6fd9947b049c2ec69bddae02bf15760d640b6c
|
|
| MD5 |
0b5b1153bf7c961e0ee1da36f25186cf
|
|
| BLAKE2b-256 |
bbf23f49384d2db1f06eba3e44486dce8c1567c99955ac8fd406119796251456
|
File details
Details for the file llm_redacted-0.2.2-py3-none-any.whl.
File metadata
- Download URL: llm_redacted-0.2.2-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fb348ec132dcbd8ff15b7a30a505ec1407ddf0a62f95e65d77034dee7f9a7f2
|
|
| MD5 |
5c0e61e63c12e085490032dcac8b51aa
|
|
| BLAKE2b-256 |
6a02788f0a7465acf14a9d30ede61a4d9f68531cd7a37da4cddccf7eeb56991f
|