Privacy Infrastructure for Enterprise AI — Official Python SDK
Project description
Privaro Python SDK
Privacy Infrastructure for Enterprise AI — Official Python SDK by iCommunity Labs
Protect PII in AI prompts with one line of code. Every interaction is tokenized, audited, and blockchain-certified.
Installation
pip install privaro
No required dependencies — uses Python stdlib only.
# Optional: async support
pip install privaro[async]
Quick Start
import privaro
# Initialize once (e.g., at app startup)
privaro.init(
api_key="prvr_your_api_key",
pipeline_id="your-pipeline-uuid",
)
# Protect a prompt before sending to any LLM
result = privaro.protect("Patient: María García, DNI 34521789X, IBAN ES91 2100...")
print(result.protected) # "Patient: [NM-0001], DNI [ID-0001], IBAN [BK-0001]..."
print(result.risk_score) # 0.847
print(result.risk_level) # "high"
print(result.gdpr_compliant) # True
# Send protected prompt to your LLM — no PII ever reaches the model
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": result.protected}]
)
Usage Patterns
Protect + LLM (full pipeline)
import privaro
import openai
privaro.init(api_key="prvr_xxx", pipeline_id="uuid")
def ask_ai(user_input: str) -> str:
# 1. Protect PII
protected = privaro.protect(user_input)
if not protected.is_safe:
raise ValueError(f"PII leak detected: {protected.leaked} entities exposed")
# 2. Call LLM with protected prompt
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": protected.protected}]
)
return response.choices[0].message.content
Detect only (analysis mode)
result = privaro.detect("Call me at 612 345 678, email: user@company.es")
for detection in result.detections:
print(f"{detection.type}: {detection.severity} ({detection.detector})")
# phone: high (regex)
# email: high (regex)
Agent mode (stricter policies)
result = privaro.protect(
prompt=agent_input,
agent_mode=True, # Applies stricter policy preset
)
Multiple clients (multiple pipelines)
from privaro import PrivaroClient
legal_client = PrivaroClient(api_key="prvr_xxx", pipeline_id="legal-pipeline-uuid")
hr_client = PrivaroClient(api_key="prvr_xxx", pipeline_id="hr-pipeline-uuid")
legal_result = legal_client.protect(contract_text)
hr_result = hr_client.protect(employee_record)
Async support
from privaro.async_client import AsyncPrivaroClient
client = AsyncPrivaroClient(api_key="prvr_xxx", pipeline_id="uuid")
async def process(prompt: str):
result = await client.protect(prompt)
return result.protected
Error handling
from privaro.exceptions import AuthError, PolicyBlockError, ProxyUnavailableError
try:
result = privaro.protect(prompt)
except PolicyBlockError as e:
# Request blocked by policy (e.g., health data on non-approved provider)
logger.warning(f"Request blocked: {e}")
return "Request cannot be processed — sensitive data detected."
except ProxyUnavailableError:
# Fallback: log and fail safely
logger.error("Privaro proxy unavailable")
raise
except AuthError:
logger.error("Invalid Privaro API key")
raise
ProtectResult Reference
| Property | Type | Description |
|---|---|---|
result.protected |
str | Prompt with PII replaced by tokens |
result.original |
str | Original prompt (local only) |
result.risk_score |
float | 0.0–1.0 composite risk score |
result.risk_level |
str | "high" / "medium" / "low" |
result.gdpr_compliant |
bool | True if no PII leaked |
result.is_safe |
bool | True if all PII masked |
result.has_pii |
bool | True if any entities detected |
result.total_detected |
int | Total PII entities found |
result.total_masked |
int | Entities successfully masked |
result.leaked |
int | Entities that passed through |
result.detections |
list[Detection] | Per-entity details |
result.audit_log_id |
str | Supabase audit log UUID |
result.processing_ms |
int | Proxy latency in ms |
result.summary() |
str | One-line log summary |
Detection Reference
| Property | Values |
|---|---|
detection.type |
dni iban email full_name phone health_record credit_card ip_address date_of_birth |
detection.severity |
critical high medium low |
detection.action |
tokenised anonymised blocked |
detection.detector |
regex presidio |
detection.confidence |
0.0–1.0 |
detection.is_high_risk |
bool |
Blockchain Verification
Every protect() call creates an immutable audit entry certified on Fantom Opera Mainnet via iBS. Verify any event at:
https://checker.icommunitylabs.com/check/fantom_opera_mainnet/{tx_hash}
Access the TX hash from your Privaro dashboard → Audit Logs → ⛓️ badge.
Requirements
- Python 3.9+
- Zero required dependencies (uses
urllibfrom stdlib) - Optional:
aiohttp>=3.9for async support
License
MIT — © 2026 iCommunity Labs · privaro.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file privaro-0.1.0.tar.gz.
File metadata
- Download URL: privaro-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46cdc9c0c6cb791161c26b91b4dd22a9964a4a96f577202fe663d8a07650010f
|
|
| MD5 |
fe263b7664f30d931950d79f31e8440c
|
|
| BLAKE2b-256 |
3a7bdf9decd163c5670671a0c4b9721dfb2405fe543943e39804bd980bb9c49a
|
File details
Details for the file privaro-0.1.0-py3-none-any.whl.
File metadata
- Download URL: privaro-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17f15564797d3c93f301cd131f67be75b11ef9370c6d018383917b86a53da026
|
|
| MD5 |
f265c691dd8e405f3795cfa460656d70
|
|
| BLAKE2b-256 |
c3c7b0f7cbe576a63363c82a1bf5bda4dd001ccf49ed58e1d5eb37cb8b2df99c
|