REST API

Use TalonAI directly via REST API from any language or platform.

Base URL

https://api.talonai.io/v1

Authentication

All requests require an API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Analyze Endpoint

POST /v1/analyze
curl https://api.talonai.io/v1/analyze \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User input to analyze",
    "options": {
      "detectPII": true,
      "detectInjection": true,
      "detectJailbreak": true
    }
  }'

Response

{
  "id": "analysis_abc123",
  "riskScore": 15,
  "riskLevel": "low",
  "isSafe": true,
  "threats": [],
  "pii": {
    "detected": false,
    "types": []
  },
  "analysis": {
    "promptInjection": { "score": 0.05, "detected": false },
    "jailbreak": { "score": 0.02, "detected": false }
  }
}

Protect Endpoint

POST /v1/protect

Analyze and optionally redact content in a single call:

curl https://api.talonai.io/v1/protect \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "My SSN is 123-45-6789",
    "redact": true
  }'

# Response
{
  "original": "My SSN is 123-45-6789",
  "protected": "My SSN is [REDACTED]",
  "redactions": [
    { "type": "ssn", "start": 10, "end": 21 }
  ]
}

Error Handling

// Error response format
{
  "error": {
    "code": "invalid_api_key",
    "message": "The provided API key is invalid",
    "status": 401
  }
}

Rate Limits

Rate limits are returned in response headers:

  • X-RateLimit-Limit - Requests per minute
  • X-RateLimit-Remaining - Remaining requests
  • X-RateLimit-Reset - Reset timestamp