REST API
Guard API
Classifies user inputs to detect malicious intent such as prompt injection, system prompt extraction, or data exfiltration attempts. Returns classification with violation types and CWE codes.
AuthorizationBearer <token>
Bearer token authentication using your API key
In: header
text?string
The user input text to analyze for security threats. At least one of text, file, or url must be provided.
file?string
Base64-encoded PDF file to analyze (format: data:application/pdf;base64,...). At least one of text, file, or url must be provided.
url?string
URL to a PDF file to download and analyze for security threats. At least one of text, file, or url must be provided.
Format
urisystem_prompt?string
Optional system prompt that allows you to steer the guard REST API behavior and customize the classification logic.
Response Body
curl -X POST "https://app.superagent.sh/api/guard" \ -H "Content-Type: application/json" \ -d '{}'{
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "superagent-lm-guard-20b",
"choices": [
{
"message": {
"role": "assistant",
"content": {
"classification": "block",
"violation_types": [
"prompt_injection",
"system_prompt_extraction"
],
"cwe_codes": [
"CWE-94"
]
},
"reasoning": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 50,
"total_tokens": 200
}
}{
"error": "Invalid text provided"
}{
"error": "API key missing"
}{
"error": "No subscription found"
}{
"error": "Team not found"
}{
"error": "Failed to analyze prompt"
}