Guardrails API Documentation
NSFW Detector
Analyses text for content that may be inappropriate for workplace environments, such as explicit language or adult themes, ensuring professionalism and compliance with workplace standards. The detector returns a binary value (0 for sfw, 1 for nsfw) indicating whether the text is not safe for work.
Example request:
import requests
import json
import os
url = "https://api.enkryptai.com/guardrails/detect"
payload = json.dumps({
"text": "This movie scene is too explicit and contains adult dialogue that might not be suitable for all audiences.",
"detectors": {
"nsfw": {
"enabled": True
},
}
})
headers = {
'Content-Type': 'application/json',
'api_key': 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:
{
"summary": {
"nsfw": 1
},
"details": {
"nsfw": {
"sfw": 0.18349984288215637,
"nsfw": 0.8089521527290344
}
}
}