Skip to main content
This detector identifies potential infinite loops or infinite recursion in the generated text. It helps prevent the model from getting stuck in an infinite loop and causing a denial of service attack.

Example request:

import requests
import json
import os

url = "https://api.enkryptai.com/guardrails/detect"

payload = json.dumps({
    "text": "All programmers are men and women can't code.",
    "detectors": {
        "sponge_attack": {
            "enabled": 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": {
    "sponge_attack": 1
  },
  "details": {
    "sponge_attack": {
      "sponge_attack_detected": true
    }
  }
}
I