Skip to main content

Python SDK for Blindfold Gateway

Project description

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.

Installation

pip install blindfold-sdk

Usage

Initialization

from blindfold import Blindfold

client = Blindfold(
    api_key="your-api-key-here",
    # Optional: Track specific end-user for audit logs
    user_id="user_123"
)

Tokenize (Reversible)

Replace sensitive data with reversible tokens (e.g., <PERSON_1>).

response = client.tokenize(
    text="Contact John Doe at john@example.com",
    config={
        "entities": ["PERSON", "EMAIL_ADDRESS"],
        "score_threshold": 0.4
    }
)

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.

original = client.detokenize(
    text="AI response for <PERSON_1>",
    mapping=response.mapping
)

print(original.text)
# "AI response for John Doe"

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"
)

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)

asyncio.run(main())

Configuration

Entity Types

Examples of supported entities:

  • PERSON
  • EMAIL_ADDRESS
  • PHONE_NUMBER
  • CREDIT_CARD
  • IP_ADDRESS
  • LOCATION
  • DATE_TIME
  • URL
  • IBAN_CODE
  • US_SSN
  • MEDICAL_LICENSE

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

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

blindfold_sdk-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blindfold_sdk-1.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file blindfold_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: blindfold_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for blindfold_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0959e2c8e19e7afb2ecbb644dee312d94ed0ba44fe4864fcb0a6804cbf761e16
MD5 13c1b9f751b9c09c82fd297a6c7aa72b
BLAKE2b-256 dd18389bc069bdac28799f07263524b9899b88eb97ebdf00e0fc902f641b8305

See more details on using hashes here.

File details

Details for the file blindfold_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: blindfold_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for blindfold_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a61756ef71fd9d0ae4caec2d0ea4cabb99f407d144d02f168ecd516d3d23e81
MD5 27a9b5d11bc813ee8e276d72d3417f58
BLAKE2b-256 dffad0d1362bab8171b24cec84dfbac55ecea3b054bc02ef85f1fe2353f57aec

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