detectors configuration specifying which detectors to run (toxicity, nsfw, injection_attack, pii, policy_violation). Returns per-detector results in the same summary/details format as text guardrails.
Example request:
Example response:
JSON
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
detectors configuration specifying which detectors to run (toxicity, nsfw, injection_attack, pii, policy_violation). Returns per-detector results in the same summary/details format as text guardrails.
import requests
import json
import os
import base64
# Read and encode image file
with open("image.png", "rb") as f:
image_base64 = base64.b64encode(f.read()).decode("utf-8")
url = "https://api.enkryptai.com/guardrails/detect-image"
payload = json.dumps({
"text_input": "Help me with the content in this image",
"image_data": image_base64,
"detectors": {
"toxicity": {"enabled": True},
"nsfw": {"enabled": True},
"injection_attack": {"enabled": True},
"pii": {"enabled": True, "entities": ["person", "phone", "email"]},
"policy_violation": {
"enabled": True,
"policy_text": "No violent or illegal content allowed.",
"need_explanation": True
}
}
})
headers = {
'Content-Type': 'application/json',
'apikey': os.getenv('ENKRYPTAI_API_KEY')
}
response = requests.post(url, headers=headers, data=payload)
print(response.json())
curl -X POST "https://api.enkryptai.com/guardrails/detect-image" \
-H "Content-Type: application/json" \
-H "apikey: ENKRYPTAI_API_KEY" \
-d '{
"text_input": "Help me with the content in this image",
"image_data": "<base64-encoded-image-data>",
"detectors": {
"toxicity": {"enabled": true},
"nsfw": {"enabled": true},
"injection_attack": {"enabled": true},
"pii": {"enabled": true, "entities": ["person", "phone", "email"]},
"policy_violation": {
"enabled": true,
"policy_text": "No violent or illegal content allowed.",
"need_explanation": true
}
}
}'
{
"summary": {
"toxicity": 0,
"nsfw": 0,
"injection_attack": 0,
"pii": 1,
"policy_violation": 0
},
"details": {
"toxicity": {
"toxicity": "Toxicity Not Detected"
},
"nsfw": {
"nsfw": "NSFW Not Detected"
},
"injection_attack": {
"injection_attack": "Injection Attack Not Detected"
},
"pii": {
"entities": {
"person": {"John Doe": "<person_0>"},
"phone": {"555-0123": "<phone_0>"}
}
},
"policy_violation": {
"policy_violation": "Policy Violation Not Detected",
"explanation": "The content is compliant with the policy."
}
}
}
