Guardrails API Documentation
Guardrails APIs
- GETHealth Check
- GETStatus Check
- GETModels Loaded
- POSTGuardrails Detect
- POSTGuardrails Batch Detect
- POSTPII anonymization and de-anonymization
- POSTDetect Hallucination
- POSTGuardrails Adherence
- POSTGuardrails Relevancy
- POSTAdd Policy
- GETGet Policy
- PATCHModify Policy
- DELDelete Policy
- GETList Policies
- POSTDetect with Policy
All Detectors Explained
Policy Violation Detector
This detector checks if the generated text adheres to specified policies or guidelines. It helps ensure that the content complies with predefined rules and standards.
Example request:
import requests
import json
import os
url = "https://api.enkryptai.com/guardrails/detect"
payload = json.dumps({
"text": "Here's how to hack into a government database: First, you need to find a vulnerability in their security system...",
"detectors": {
"policy_violation": {
"enabled": True,
"policy_text": "",
"need_explanation": True
}
}
})
headers = {
'Content-Type': 'application/json',
'apikey': os.getenv('ENKRYPTAI_API_KEY')
}
response = requests.request("POST", url, headers=headers, data=payload)
formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)
Example response:
JSON
{
"summary": {
"policy_violation": 0
},
"details": {
"policy_violation": {
"violating_policy": "Content Security Policy",
"explanation": "The text provides instructions on illegal activities, specifically hacking into government databases, which violates our content security policy."
}
}
}
On this page