Risk Scoring

Understand how TalonAI calculates risk scores and how to use them in your application.

What is Risk Scoring?

Every request analyzed by TalonAI receives a risk score between 0 and 100. This score represents the overall threat level of the content based on multiple detection factors.

0-30
Low Risk
31-70
Medium Risk
71-100
High Risk

Score Components

The risk score is calculated from multiple weighted factors:

FactorWeightDescription
Prompt Injection35%Likelihood of injection attack
Jailbreak30%Jailbreak attempt probability
PII Exposure20%Sensitive data detected
Policy Violations15%Custom policy matches

Using Risk Scores

const result = await talon.analyze({ content: userInput });

console.log(result.riskScore); // 0-100
console.log(result.riskLevel); // 'low' | 'medium' | 'high'

// Take action based on risk
if (result.riskScore > 70) {
  // Block high-risk requests
  throw new Error('Request blocked due to high risk');
} else if (result.riskScore > 30) {
  // Flag medium-risk for review
  await logForReview(result);
}

// Low risk - proceed normally

Configuring Thresholds

Set custom thresholds to automatically block or flag requests:

const talon = new TalonAI({
  thresholds: {
    block: 80,    // Auto-block above 80
    flag: 50,     // Auto-flag above 50
    allow: 30,    // Auto-allow below 30
  }
});

Detailed Breakdown

Each analysis result includes a detailed breakdown of individual threat scores, allowing you to understand exactly why a request received its risk score.