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-2.1.0.tar.gz (51.1 kB view details)

Uploaded Source

Built Distribution

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

ciphyrs-2.1.0-py3-none-any.whl (79.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ciphyrs-2.1.0.tar.gz
Algorithm Hash digest
SHA256 8e138c1b28741ea3dbfcc2828af7fdaed4ada8857d6a789870a6d9dee2dc6118
MD5 a8cf8bd976f6c33000587fa09e1de833
BLAKE2b-256 2faed4ee90ae1872c05ab8168ca945e4db9e0a493373adba7fee4a59b1b3f634

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ciphyrs-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 79.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-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b398cead0fb6a084d48686ad2e7754c83ad3d62e4aa66c15233008f2817c2df
MD5 6fcc75c20d0c848a3f7f13b80903ec08
BLAKE2b-256 f490924cfcf611911d159a966d96c3ca1d699279550061c62ffd2d348568b52f

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