Python SDK for the Ciphyrs PII Shield API
Project description
Ciphyrs — PII Shield for AI Workflows
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.
- Register at ciphyrs.com/register
- Go to Settings > API Keys
- Click Generate API Key
- 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 |
| 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-2.0.0.tar.gz
(32.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ciphyrs-2.0.0-py3-none-any.whl
(50.9 kB
view details)
File details
Details for the file ciphyrs-2.0.0.tar.gz.
File metadata
- Download URL: ciphyrs-2.0.0.tar.gz
- Upload date:
- Size: 32.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cda17e22298b18837428936313a439a7273f92ef58a35f03f57fa308a36b7d6f
|
|
| MD5 |
c8697303ec3a482366f4e651f11af96e
|
|
| BLAKE2b-256 |
587d3eb98370ef00d19e5187624d482c9c6f4981f995fa310214d6bd0aa3086e
|
File details
Details for the file ciphyrs-2.0.0-py3-none-any.whl.
File metadata
- Download URL: ciphyrs-2.0.0-py3-none-any.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7533e5b03c3f4b6d945aae9f7222ade7f9afd7a7c4bc9d4ecf13c797e8cbc71
|
|
| MD5 |
ddd5900cd1de32aeffb2a9cf4420fbc2
|
|
| BLAKE2b-256 |
226618c52cf520461cbe85c7dded9576d14a09678b6fd9b6e4d4f79f6087e52e
|