Analyze API
Analyze content for threats, PII, and policy violations.
Endpoint
POST /v1/analyzeRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| content | string | Yes | The content to analyze |
| direction | string | No | "input" or "output" (default: "input") |
| policies | string[] | No | Policy IDs to apply |
| metadata | object | No | Additional context (user_id, etc.) |
Example Request
curl https://api.talonai.io/v1/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Can you help me with my account?",
"direction": "input",
"policies": ["default"],
"metadata": {
"user_id": "user_123",
"session_id": "sess_abc"
}
}'Response
{
"id": "analysis_abc123def456",
"riskScore": 12,
"riskLevel": "low",
"isSafe": true,
"blocked": false,
"blockReason": null,
"threats": [],
"pii": {
"detected": false,
"types": [],
"locations": []
},
"analysis": {
"promptInjection": {
"score": 0.03,
"detected": false,
"patterns": []
},
"jailbreak": {
"score": 0.01,
"detected": false,
"patterns": []
},
"toxic": {
"score": 0.02,
"detected": false,
"categories": []
}
},
"policies": {
"evaluated": ["default"],
"violations": []
},
"latency": 23
}Error Codes
| Code | Description |
|---|---|
| 400 | Invalid request body |
| 401 | Invalid or missing API key |
| 429 | Rate limit exceeded |
| 500 | Internal server error |