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:
Copy
Ask AI
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,
"need_explanation": True
"policy_text": "Do not allow any illegal or immoral activities."
# Or we can also give coc_policy_name of a saved Code of Conduct Policy
# Instead of policy_text
# "coc_policy_name": "Test CoC Policy"
}
}
})
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
Copy
Ask AI
{
"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
Assistant
Responses are generated using AI and may contain mistakes.