Universal compliance packet SDK for Python.
Project description
🐍 Compliance Packet — Python SDK
Official Python client for the Compliance Packet API — a universal safety, copyright, privacy, and compliance scoring system for AI applications.
This SDK provides a clean, typed interface for:
- Running compliance checks
- Retrieving usage statistics
- Handling structured errors
- Integrating moderation into Python agents, backends, and workflows
📦 Installation
Install from PyPI:
pip install compliance-packet
🚀 Quickstart
from compliance_packet import ComplianceClient, CompliancePacketError
client = ComplianceClient(api_key="cpk_your_key_here")
try:
packet = client.check("Hello, world!")
print("Safety:", packet.safety.score)
print("Recommendation:", packet.overall.recommendation)
usage = client.usage()
print("Checks used:", usage.summary["totalChecks"])
except CompliancePacketError as e:
print("API error:", e.code, "-", e.message)
🧠 API Overview
Initialize client
client = ComplianceClient(api_key="cpk_1234")
Run a compliance check
packet = client.check("some text")
Response structure
Each check returns a structured CompliancePacket:
packet.safety.score
packet.safety.category
packet.privacy.piiDetected
packet.copyright.assessment
packet.overall.complianceScore
packet.meta.inputId
Full packet fields mirror the backend specification.
🔥 Error Handling
All API errors raise CompliancePacketError.
Each error has:
code— machine-readable codemessage— human-readable explanationstatus— HTTP status code
Example:
try:
client.check("hello")
except CompliancePacketError as err:
print(err.code) # "AUTH_INVALID_API_KEY"
print(err.message) # "Invalid or inactive API key."
print(err.status) # 401
📊 Usage Endpoint
usage = client.usage()
print(usage.summary)
Example summary:
{
"totalChecks": 42,
"allow": 40,
"review": 1,
"block": 1
}
🔒 Authentication
All requests require:
client = ComplianceClient(api_key="cpk_xxx")
If the key is invalid, a CompliancePacketError is raised with:
code: AUTH_INVALID_API_KEY
status: 401
🛠 Development
Install editable version:
pip install -e .
Run tests:
python test-client.py
🌐 Links
- API Documentation: https://your-frontend-domain.com/docs
- JavaScript SDK: https://www.npmjs.com/package/compliance-packet
- Python SDK (PyPI): https://pypi.org/project/compliance-packet/
⚠️ Disclaimer
Compliance Packet provides probabilistic analysis, not legal advice.
Use human review for high-stakes or regulated applications.
📄 License
MIT
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 compliance_packet-0.1.1.tar.gz.
File metadata
- Download URL: compliance_packet-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5883e8f7a4a84f7884c491119322c0dffd6a54ebfaea6853522fc8ca68fdf352
|
|
| MD5 |
4def705ca59631f5850d223c661bbd47
|
|
| BLAKE2b-256 |
bfd5bfb33f9ef3e863f7ceb495e2fe9870b8858d88df00700a94d61d783dca6a
|
File details
Details for the file compliance_packet-0.1.1-py3-none-any.whl.
File metadata
- Download URL: compliance_packet-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a0623ded793c2418f8bfde1358371a5e934e10127f7c9363052074fbc92e213
|
|
| MD5 |
9487d0c13db86e95de44dd6287f8a5df
|
|
| BLAKE2b-256 |
a18b1e806a000a9db78c02d4d339e0df286658dc654fcd09d0c330b31ce7d2fa
|