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-")
Metadata
Release files for llm-redacted 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm_redacted-0.2.2.tar.gz | 11.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_redacted-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.9 kB
Release files / llm_redacted-0.2.2.tar.gz
| Download URL | llm_redacted-0.2.2.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9377a68487aa0326a6df80985b6fd9947b049c2ec69bddae02bf15760d640b6c
|
|
BLAKE2b-256 checksum How to use checksums |
bbf23f49384d2db1f06eba3e44486dce8c1567c99955ac8fd406119796251456
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / llm_redacted-0.2.2-py3-none-any.whl
| Download URL | llm_redacted-0.2.2-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fb348ec132dcbd8ff15b7a30a505ec1407ddf0a62f95e65d77034dee7f9a7f2
|
|
BLAKE2b-256 checksum How to use checksums |
6a02788f0a7465acf14a9d30ede61a4d9f68531cd7a37da4cddccf7eeb56991f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for llm-redacted 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.