Analyze API

Analyze content for threats, PII, and policy violations.

Endpoint

POST /v1/analyze

Request Body

ParameterTypeRequiredDescription
contentstringYesThe content to analyze
directionstringNo"input" or "output" (default: "input")
policiesstring[]NoPolicy IDs to apply
metadataobjectNoAdditional 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

CodeDescription
400Invalid request body
401Invalid or missing API key
429Rate limit exceeded
500Internal server error