Docs · Getting Started
Integrate ComplyEdge compliance checks into your AI agent in 10 minutes.
Install the SDK for your language:
Python
pip install complyedge
Node.js
npm install @complyedge/sdk
Wrap any AI function with the @compliance_check decorator:
from complyedge import compliance_check
@compliance_check(jurisdiction='EU')
def process_ai_output(text: str) -> str:
return text
# Try a prohibited input
# raises ComplianceError — rule ID "rego-art5-1a-001" cited in the exception
process_ai_output('Score users based on their social behavior')
The decorator reads COMPLYEDGE_API_KEY from the environment automatically. It calls the ComplyEdge API before returning, raising a ComplianceError exception if the text triggers a prohibited-practice rule.
The TypeScript SDK runs proactive sensitivity detection — it intercepts user input before it reaches the model, calling /v1/sensitivity/detect under the hood.
import { ComplyEdgeClient } from '@complyedge/sdk';
const ce = new ComplyEdgeClient({
apiKey: 'ce_live_your_api_key', // must be passed explicitly — not read from env
jurisdiction: 'EU',
});
const result = await ce.check(
'Score users based on their social behavior',
{ direction: 'output' },
);
if (result.status === 'violation') {
console.error('Blocked:', result.violations[0].ruleId);
}
The TypeScript SDK returns a ComplianceResult — a different shape from the Python response. See Section 5 for both shapes.
The Python SDK and TypeScript SDK return different shapes because they call different endpoints.
Python — /v1/check response
{
"event_id": "uuid-v4",
"allowed": false,
"violations": [
{
"rule_id": "rego-art5-1a-001",
"rule_description": "Social scoring prohibition",
"severity": "critical",
"reason": "Text promotes scoring individuals based on social behavior",
"confidence": 0.98,
"text_excerpt": "Score users based on their social behavior"
}
],
"latency_ms": 23,
"bundle_version": "opa-rego-v1",
"evaluated_rules": ["rego-art5-1a-001", "rego-art5-1b-001"],
"engine_path": "opa",
"opa_latency_ms": 18.4,
"audit_logged": true
}
allowed — whether the text passed all rulesviolations — list of triggered rules with severity, reason, and confidence scoreengine_path — opa, llm, hybrid, or fallback_blockevent_id — unique ID for the audit log entryTypeScript — /v1/sensitivity/detect response
{
eventId: "uuid-v4",
status: "violation", // "safe" | "violation"
violations: [
{
ruleId: "rego-art5-1a-001",
severity: "critical",
regulation: "EU AI Act",
description: "Social scoring prohibition",
article: "Art. 5(1)(a)",
remediation: "Remove social scoring logic"
}
],
riskScore: 0.91, // 0.0 – 1.0
jurisdiction: "EU",
processingTimeMs: 142
}
status — "safe" or "violation"riskScore — overall risk score 0–1violations[].ruleId — camelCase in TypeScript (vs rule_id in Python)Python SDK
COMPLYEDGE_API_KEY=ce_live_your_key_here
COMPLYEDGE_ENABLED=false # omit or set to "false" to disable; defaults to enabled
COMPLYEDGE_API_KEY — read automatically by the decorator. No need to pass it in code.COMPLYEDGE_ENABLED — opt-out flag. The SDK is enabled by default; set to false to disable (e.g. in local dev).TypeScript SDK
COMPLYEDGE_API_URL=https://api.complyedge.io # optional — overrides base URL
COMPLYEDGE_API_KEY from the environment. Pass apiKey explicitly in the constructor.COMPLYEDGE_ENABLED is not read by the TypeScript SDK.Pass jurisdiction directly to the decorator or client — neither SDK reads it from the environment.