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.1.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.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ciphyrs-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 00d6e8a02dd1c6265ed8065c99fd6cde1eb56dfe7bdcfe4c937e99cf522d9e51
MD5 48afdd788cece73b8893185176359be8
BLAKE2b-256 b0aebbba20e849f5b472c8c18d24b3c16738a5891c2100f304d99c35fc894e9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ciphyrs-1.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0bf10b4b59b65aa3b154e875324396246e296481219ae37127b877405429567
MD5 5b0fa8f38a687942caa00f7119de8673
BLAKE2b-256 8687a6a5584b2b1b91ce3e979b0c6078bd97fdd9af183bcb325fb37bb8c9f19d

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