Python SDK for LetsComplai PII/PHI redaction and compliance gateway
Project description
LetsComplai Python SDK
Python SDK for the LetsCompl.ai PII/PHI redaction engine and compliance API gateway.
Installation
pip install letscomplai
Usage
Local Redaction
from letscomplai import redact
payload = {
"name": "The patient John Doe was diagnosed.",
"email": "test@example.com",
"ssn": "000-12-3456",
}
result = redact(payload)
print(result["redacted"])
# {
# "name": "patient [REDACTED_NAME] was diagnosed.",
# "email": "[REDACTED_EMAIL]",
# "ssn": "[REDACTED_SSN]"
# }
print(result["hits"]) # ['SSN', 'EMAIL', 'NAME']
Remote Evaluation
from letscomplai import LetsComplaiClient
client = LetsComplaiClient(api_key="your-api-key")
result = client.evaluate({
"patient_notes": "Mr. John Smith has a history of asthma.",
})
print(result)
By default, evaluate() redacts PII/PHI locally, before the payload is sent to the gateway — raw sensitive data never leaves your process. Pass redact=False as an explicit opt-out to send the raw, unredacted payload:
client.evaluate(payload, redact=False) # explicit opt-out — sends the raw payload
evaluate() also accepts rules (a list of rule keys to restrict evaluation to a subset instead of the full workspace policy) and pinned_versions (a dict mapping ruleset key to a historical version number, for audit replay):
client.evaluate(payload, rules=["ftc_budget_cap"], pinned_versions={"ftc_budget_cap": 2})
Passing rules makes the response's policyScope "filtered" instead of "full", with evaluatedRules listing exactly which rule keys ran. A "filtered" response is not a complete compliance decision — it only reflects the requested subset, not the workspace's full active policy. Omit rules to evaluate everything.
Guarding an action
from letscomplai import LetsComplaiClient
client = LetsComplaiClient(api_key="your-api-key")
result = client.guard_action(
{"action": "payout", "amount": 1200},
lambda: payments.create_payout(amount=1200),
)
guard_action raises ComplianceBlockedError if the verdict is blocked, and (by default) ComplianceUnavailableError if the gateway is unreachable, before the action callable runs.
Async client
from letscomplai import AsyncLetsComplaiClient
client = AsyncLetsComplaiClient(api_key="your-api-key")
result = await client.evaluate({"action": "payout", "amount": 1200})
await client.aclose()
AsyncLetsComplaiClient mirrors LetsComplaiClient's evaluate/guard_action/redact_local methods for asyncio applications.
LetsCompl.ai is a technical enforcement tool, not a legal compliance service. Verdicts do not constitute legal advice.
For timeout, fail-open/fail-closed, retry, SLA, and local-enforcement behavior, see docs/operations/client-availability.md.
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 letscomplai-0.1.0.tar.gz.
File metadata
- Download URL: letscomplai-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a4fafda098c43803b45108c7f29325d86b2f00f6ae58e4065c26a2daf4a9b1d
|
|
| MD5 |
0e8e71804b7594d360744bb67e89b0d4
|
|
| BLAKE2b-256 |
214b04007ca1052f6d511a435e30ca7d02de3f2e566199e59a6e4482182f29c6
|
File details
Details for the file letscomplai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: letscomplai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aed964f522cb39e776f2a17fe714130afd9bc990fe5e4c269338bd2bb4f5e512
|
|
| MD5 |
54bda75058a3156327306ba4cb50449e
|
|
| BLAKE2b-256 |
6ab87fe19a26f78c795ff19a7aba5439ec79184ba5d7228c9b1f9e7ed4eedbaa
|