Blindfold Python SDK
The official Python SDK for Blindfold - The Privacy API for AI.
Securely tokenize, mask, redact, and encrypt sensitive data (PII) before sending it to LLMs or third-party services.
How to use it
1. Install SDK
pip install blindfold-sdk
2. Get Blindfold API key
BLINDFOLD_API_KEY=sk-***
Initialization
from blindfold import Blindfold
client = Blindfold()
Tokenize (Reversible)
Replace sensitive data with reversible tokens (e.g., <Person_1>).
response = client.tokenize(
text="Contact John Doe at john@example.com",
policy="gdpr_eu", # Optional: Use a pre-configured policy (e.g., 'hipaa_us', 'basic')
entities=["person", "email address"], # Optional: Filter specific entities
score_threshold=0.4 # Optional: Set confidence threshold
)
print(response.text)
# "Contact <Person_1> at <Email Address_1>"
print(response.mapping)
# { "<Person_1>": "John Doe", "<Email Address_1>": "john@example.com" }
Detokenize
Restore original values from tokens.
⚡ Note: Detokenization is performed client-side for better performance, security, and offline support. No API call is made.
# Runs locally - no API call!
original = client.detokenize(
text="AI response for <Person_1>",
mapping=response.mapping
)
print(original.text)
# "AI response for John Doe"
print(original.replacements_made)
# 1
Mask
Partially hide sensitive data (e.g., ****-****-****-1234).
response = client.mask(
text="Credit card: 4532-7562-9102-3456",
masking_char="*",
chars_to_show=4,
from_end=True
)
print(response.text)
# "Credit card: ***************3456"
Redact
Permanently remove sensitive data.
response = client.redact(
text="My password is secret123"
)
Hash
Replace data with deterministic hashes (useful for analytics/matching).
response = client.hash(
text="User ID: 12345",
hash_type="sha256",
hash_prefix="ID_"
)
Synthesize
Replace real data with realistic fake data.
response = client.synthesize(
text="John lives in New York",
language="en"
)
print(response.text)
# "Michael lives in Boston" (example)
Encrypt
Encrypt sensitive data using AES (reversible with key).
response = client.encrypt(
text="Secret message",
encryption_key="your-secure-key-min-16-chars"
)
Batch Processing
Process multiple texts in a single request (max 100 texts):
result = client.tokenize_batch(
["Contact John Doe", "jane@example.com", "No PII here"],
policy="gdpr_eu"
)
print(result.total) # 3
print(result.succeeded) # 3
print(result.failed) # 0
for item in result.results:
print(item["text"])
All methods have batch variants: tokenize_batch, detect_batch, redact_batch, mask_batch, synthesize_batch, hash_batch, encrypt_batch.
Async Usage
The SDK also supports asyncio:
import asyncio
from blindfold import AsyncBlindfold
async def main():
async with AsyncBlindfold(api_key="...") as client:
response = await client.tokenize("Hello John")
print(response.text)
# Note: detokenize is also synchronous in async client (no await)
original = client.detokenize(response.text, response.mapping)
print(original.text)
asyncio.run(main())
Configuration
Entity Types
Common supported entities:
personemail addressphone numbercredit card numberip addressaddressdate of birthorganizationibansocial security numbermedical conditionpassport numberdriver's license number
Error Handling
The SDK raises specific exceptions:
from blindfold.errors import AuthenticationError, APIError, NetworkError
try:
client.tokenize("...")
except AuthenticationError:
# Handle invalid API key
pass
except APIError as e:
# Handle API error (e.g. validation)
print(e)
except NetworkError:
# Handle network issues
pass
Metadata
Release files for blindfold-sdk 1.3.0
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 | |
|---|---|---|---|---|
| blindfold_sdk-1.3.0.tar.gz | 24.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blindfold_sdk-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.7 kB
Release files / blindfold_sdk-1.3.0.tar.gz
| Download URL | blindfold_sdk-1.3.0.tar.gz |
|---|---|
| Size | 24.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d46044cfdaca35fc6b5255218abc9342aca56422bd7867ee90d33e36c8801b3
|
|
BLAKE2b-256 checksum How to use checksums |
34fcca95ac8fb39f7ba1676be02db9d370c929907bccb9b95cd19887759590e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / blindfold_sdk-1.3.0-py3-none-any.whl
| Download URL | blindfold_sdk-1.3.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2480617a9ef227022da4faa154ab4177d4a8436f85ab15277bc123df6dcd6e73
|
|
BLAKE2b-256 checksum How to use checksums |
2c8de285ff6df304ccc5d11eef083bd4cabddc252d595a77846ae67c9dc9fb5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for blindfold-sdk 1.3.0
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.