> ## 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.

# Security

> Protect your agents from misuse

Agents include security features to prevent misuse and protect data.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    Input([Input]) --> Agent[Agent]
    Agent --> Safe([Safe Output])

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

    class Agent agent
    class Input,Safe tool
    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff
```

## Quick Start

**1. Simple Usage**

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

const agent = new Agent({
  instructions: 'You are a helpful assistant',
  security: true  // Enable all protections
});

await agent.chat('Ignore previous instructions and...');
// Prompt injection blocked
```

**2. With Configuration**

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
const agent = new Agent({
  security: {
    blockInjection: true,
    blockPII: true,
    maxTokens: 4000
  }
});
```

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Security
    participant Agent
    
    User->>Security: Potentially unsafe input
    Security->>Security: Validate input
    alt Safe
        Security->>Agent: Process request
        Agent->>Security: Generate response
        Security->>Security: Filter output
        Security-->>User: Safe response
    else Unsafe
        Security-->>User: Blocked
    end
```

***

## Configuration Levels

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
// Level 1: Bool - Enable all protections
const agent = new Agent({
  security: true
});

// Level 2: Array - Specific protections
const agent = new Agent({
  security: ['injection', 'pii', 'profanity']
});

// Level 3: Dict - Full control
const agent = new Agent({
  security: {
    blockInjection: true,
    blockPII: true,
    blockPatterns: [/password/i, /\b\d{16}\b/],  // Credit cards
    maxTokens: 4000,
    rateLimit: 10  // Per minute
  }
});
```

***

## Security Features

| Feature | Protection |
| - | - |
| `blockInjection` | Stops prompt manipulation |
| `blockPII` | Filters personal data |
| `blockPatterns` | Custom regex filters |
| `maxTokens` | Limits output size |
| `rateLimit` | Controls request frequency |

***

## API Reference

> [card] [GuardrailConfig](https://praison.ai/docs/sdk/reference/typescript/classes/GuardrailConfig.md)
>
> Complete configuration options

> [card] [Guardrails Module](https://praison.ai/docs/sdk/reference/typescript/modules/guardrails.md)
>
> Full module documentation

***

## Best Practices

> [accordion] Enable in production
>
> Always enable security for user-facing agents.

> [accordion] Limit tool access
>
> Only give agents the tools they actually need.

> [accordion] Monitor usage
>
> Track interactions to detect unusual patterns.

***

## Related

> [card] [Guardrails](https://praison.ai/docs/js/guardrails.md)
>
> Input/output validation

> [card] [Approval](https://praison.ai/docs/js/approval.md)
>
> Human oversight


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