Skip to main content

maskflow

Mask PII before it reaches an LLM. Unmask the response. Works with any provider.

from maskflow import mask_and_call

def call_claude(masked_prompt: str) -> str:
    return anthropic_client.messages.create(
        model="claude-sonnet-5",
        max_tokens=1024,
        messages=[{"role": "user", "content": masked_prompt}],
    ).content[0].text

response = mask_and_call(
    "Hi, I'm Jane Doe (jane@example.com). My order shipped to 123 Main St but never arrived.",
    call_claude,
)
# Claude only ever sees "Hi, I'm <PERSON_NAME_1> (<EMAIL_1>). My order shipped to
# <ADDRESS_1> but never arrived." -- response comes back with the real values restored.

Install

pip install maskflow-sdk

Why this shape

mask_and_call takes a plain function, not a specific provider's client. You write the one line that actually calls your LLM (Claude, OpenAI, Gemini, a local model, anything) -- maskflow never parses or depends on any provider's SDK, so it doesn't break when a provider changes their API and works with providers it's never heard of.

response = mask_and_call(prompt, lambda masked: my_llm_client.generate(masked))

Lower-level API

For more control than the wrapper gives, mask/unmask are available directly and are pure, stateless functions -- no files, no database. Persisting the mapping between calls is your responsibility.

from maskflow import mask, unmask

result = mask("Email me at alice@example.com.")
result.masked_text  # "Email me at <EMAIL_1>."
result.mapping       # {"<EMAIL_1>": "alice@example.com"}

unmask(result.masked_text, result.mapping)  # original text, restored

What gets detected

Email, phone, SSN, credit card, IP address, AWS access key, API key / generic secret, JWT, IBAN, street address, person name, date of birth -- via regex + structural validation (Luhn, mod-97, etc.) plus spaCy NER for names and dates, with keyword-context confidence boosting. See maskflow-core for detection internals.

Tests

uv run pytest

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maskflow_sdk-0.1.0.tar.gz (123.8 kB view details)

Uploaded Source

Built Distribution

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

maskflow_sdk-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file maskflow_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: maskflow_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 123.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for maskflow_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 850e7573f2231187cecf1ea4067f06ebe01e88133cb078d3c49963406055946f
MD5 ec4df50effc899b08b6e9f06e5e2610b
BLAKE2b-256 43b0868bb6acde2d516f7a5f0dd98290a9f5b0da7b9d5e913a40ec0678a28495

See more details on using hashes here.

Provenance

The following attestation bundles were made for maskflow_sdk-0.1.0.tar.gz:

Publisher: release-sdk-python.yml on maskflow/maskflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maskflow_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: maskflow_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for maskflow_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f77db93874622f2de80cf89a7f4f163567fa2485d8ecdfec22d552b614f2ddb
MD5 3b451e895764d4a9db3d548a0d3314c8
BLAKE2b-256 b8267c6433ebf5c59f804f11f1916aeda22ff0a98c5015de9d90789dd021f2dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for maskflow_sdk-0.1.0-py3-none-any.whl:

Publisher: release-sdk-python.yml on maskflow/maskflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page