Skip to main content

Python SDK for the Ciphyrs PII Shield API

Project description

Ciphyrs — PII Shield for AI Workflows

PyPI Python License: MIT

Intercept, mask, and restore PII before it reaches any LLM. Works with LangChain, CrewAI, or any Python application.

Install

pip install ciphyrs                  # core SDK
pip install 'ciphyrs[langchain]'     # + LangChain integration
pip install 'ciphyrs[crewai]'        # + CrewAI integration
pip install 'ciphyrs[all]'           # everything

Quick Start

from ciphyrs import CiphyrsClient

client = CiphyrsClient(
    api_key="cyp_live_...",
    base_url="https://www.ciphyrs.com"
)

# Mask PII
result = client.mask("Contact Praveen at 9876125640 and praveen@acme.com")
print(result.masked_text)
# "Contact XXXX_a1b2c3 at XXXX_d4e5f6 and XXXX_g7h8i9"

# Restore PII
restored = client.restore(result.masked_text, result.session_id)
print(restored.restored_text)
# "Contact Praveen at 9876125640 and praveen@acme.com"

Authentication

All API calls require an x-api-key header. Get your API key from the Ciphyrs Dashboard.

  1. Register at ciphyrs.com/register
  2. Go to Settings > API Keys
  3. Click Generate API Key
  4. Copy the key (starts with cyp_live_)

LangChain Integration

Option 1: Callback Handler (auto-masks all LLM calls)

from langchain_openai import ChatOpenAI
from ciphyrs.integrations.langchain import CiphyrsPIICallback

callback = CiphyrsPIICallback(api_key="cyp_live_...")
llm = ChatOpenAI(model="gpt-4o", callbacks=[callback])

# PII is automatically masked before reaching OpenAI
# and restored in the response
result = llm.invoke("Hi, I'm Praveen Kumar, my phone is 9876125640")

Option 2: LCEL Runnables (pipe operator)

from ciphyrs.integrations.langchain import CiphyrsMaskRunnable, CiphyrsRestoreRunnable

session = {}
mask = CiphyrsMaskRunnable(api_key="cyp_live_...", session_store=session)
restore = CiphyrsRestoreRunnable(api_key="cyp_live_...", session_store=session)

# Build pipeline: mask -> prompt -> llm -> restore
chain = mask | prompt_template | llm | restore
result = chain.invoke({"input": "Call Praveen at 9876125640"})

Option 3: Shield Wrapper (wrap any chain)

from ciphyrs.integrations.langchain import CiphyrsShield

shield = CiphyrsShield(api_key="cyp_live_...")
safe_chain = shield.wrap(my_existing_chain)
result = safe_chain.invoke({"input": "Praveen's email is praveen@acme.com"})

Async Support

from ciphyrs import AsyncCiphyrsClient

async with AsyncCiphyrsClient(api_key="cyp_live_...") as client:
    result = await client.mask("Contact Praveen at praveen@acme.com")
    restored = await client.restore(result.masked_text, result.session_id)

Detected Entity Types

Entity Example
PERSON Praveen Kumar
EMAIL praveen@acme.com
PHONE 9876125640
IN_AADHAAR 2345 6789 0123
IN_PAN ABCDE1234F
CREDIT_CARD 4111-1111-1111-1111
IP_ADDRESS 192.168.1.1
DATE_OF_BIRTH 15/03/1990
LOCATION Mumbai
ORGANIZATION Acme Corp
API_KEY sk-abc123...

Links

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

ciphyrs-1.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

ciphyrs-1.1.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file ciphyrs-1.1.0.tar.gz.

File metadata

  • Download URL: ciphyrs-1.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ciphyrs-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1c8cad12a9e8bb686571054d99c1863f7121fae613c9ee0a4f088dc2db3b9d27
MD5 90acafb6a395bbe518f586fa62ce8662
BLAKE2b-256 34e4005aa8d37737e7ba6763c9c034e2df67dd96303dd3a6aa214eecc8b6b91b

See more details on using hashes here.

File details

Details for the file ciphyrs-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ciphyrs-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ciphyrs-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6488f8d323ff189f4df52a60adfc148ee15d66a0b3e05edd9b46d0824629fa87
MD5 18cba4eabb81e81e32722769651a20b9
BLAKE2b-256 9d90622a308d100e5d564e68b61e514c68e71ea29324bfd87dbd86da05b5f06a

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