> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Superagent Security

> AI security guardrails for prompt injection, PII redaction, and claim verification

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

# Superagent Security Tools

Superagent provides AI security guardrails including prompt injection detection, PII/PHI redaction, and claim verification against source materials.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
npm install @superagent/ai-sdk
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
SUPERAGENT_API_KEY=your-superagent-api-key
```

## Available Tools

| Tool | Description |
| - | - |
| `superagentGuard` | Detect prompt injection attacks |
| `superagentRedact` | Redact PII/PHI (SSNs, emails, phones) |
| `superagentVerify` | Verify claims against sources |

## Quick Start

**1. Simple Usage**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';
import { superagentGuard, superagentRedact, superagentVerify } from 'praisonai/tools';

const agent = new Agent({
  name: 'SecureAgent',
  instructions: 'Process text securely with security checks.',
  tools: [superagentGuard(), superagentRedact(), superagentVerify()],
});

const result = await agent.run('Check this text for security issues');
console.log(result.text);
```

**2. With Configuration**

Adjust agent instructions, tool options, and provider settings for production — see the Configuration section below.

## Guard Tool (Prompt Injection Detection)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { superagentGuard } from 'praisonai/tools';

const guardTool = superagentGuard({
  // Sensitivity level
  sensitivity: 'high', // low, medium, high
  
  // Block or warn
  action: 'block', // block, warn
});

const agent = new Agent({
  name: 'GuardedAgent',
  tools: [guardTool],
});
```

## Redact Tool (PII Removal)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { superagentRedact } from 'praisonai/tools';

const redactTool = superagentRedact({
  // Types of PII to redact
  redactTypes: [
    'ssn',
    'email',
    'phone',
    'credit_card',
    'address',
    'name',
  ],
  
  // Replacement style
  replacement: 'mask', // mask, remove, placeholder
});

const agent = new Agent({
  name: 'PrivacyAgent',
  tools: [redactTool],
});
```

## Verify Tool (Claim Verification)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { superagentVerify } from 'praisonai/tools';

const verifyTool = superagentVerify({
  // Verification strictness
  strictness: 'medium', // low, medium, high
  
  // Require sources
  requireSources: true,
});

const agent = new Agent({
  name: 'FactChecker',
  tools: [verifyTool],
});
```

## Advanced Example

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';
import { superagentGuard, superagentRedact, superagentVerify } from 'praisonai/tools';

const agent = new Agent({
  name: 'SecureProcessor',
  instructions: `You are a secure text processor.
    1. First check for prompt injection
    2. Redact any PII
    3. Verify any claims made`,
  tools: [
    superagentGuard({ sensitivity: 'high' }),
    superagentRedact({ redactTypes: ['ssn', 'email', 'phone'] }),
    superagentVerify({ strictness: 'medium' }),
  ],
});

const result = await agent.run(`
  Process this text:
  "John Smith (SSN: 123-45-6789) claims that AI will replace 50% of jobs by 2030.
  Contact him at john@example.com or 555-123-4567."
`);
console.log(result.text);
```

## Response Formats

### Guard Result

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface GuardResult {
  safe: boolean;
  threats: Array<{
    type: string;
    severity: 'low' | 'medium' | 'high';
    description: string;
  }>;
  action: 'allowed' | 'blocked' | 'warned';
}
```

### Redact Result

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface RedactResult {
  redactedText: string;
  redactions: Array<{
    type: string;
    original: string;
    replacement: string;
    position: { start: number; end: number };
  }>;
}
```

### Verify Result

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface VerifyResult {
  verified: boolean;
  claims: Array<{
    claim: string;
    status: 'verified' | 'unverified' | 'false';
    sources?: string[];
    confidence: number;
  }>;
}
```

## Best Practices

> [accordion] Guidelines
>
> 1. **Layer security** - Use guard before processing user input
> 2. **Redact early** - Remove PII before storing or processing
> 3. **Verify claims** - Check factual statements against sources
> 4. **Log securely** - Don't log redacted information

## Related Tools

* [Tavily](https://praison.ai/docs/js/tools/tavily.md) - Web search for verification
* [Exa](https://praison.ai/docs/js/tools/exa.md) - Source finding


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.