Quick Start

Get LLMGuard Pro running in your application in under 5 minutes. This guide covers the essential steps to start protecting your LLM interactions.

1. Installation

Install the LLMGuard Pro SDK using your preferred package manager:

# npm
npm install @llmguard/pro

# yarn
yarn add @llmguard/pro

# Python
pip install llmguard-pro

2. Authentication

Get your API key from the dashboard and set it as an environment variable:

# .env file
LLMGUARD_API_KEY=lgp_sk_your_api_key_here
LLMGUARD_PROJECT_ID=your_project_id

3. Basic Configuration

Initialize the client and configure your security scanners:

import { LLMGuard } from '@llmguard/pro';

const guard = new LLMGuard({
  apiKey: process.env.LLMGUARD_API_KEY,
  scanners: {
    promptInjection: { enabled: true, sensitivity: 'high' },
    piiAnonymization: { enabled: true },
    dataLeakage: { enabled: true },
    toxicity: { enabled: true, threshold: 0.8 },
  }
});

4. Scanning Prompts

Wrap your LLM calls with the guard to automatically scan inputs and outputs:

// Scan input before sending to LLM
const inputResult = await guard.scanInput(userPrompt);

if (inputResult.isClean) {
  // Safe to send to LLM
  const response = await openai.chat.completions.create({...});

  // Scan output before returning to user
  const outputResult = await guard.scanOutput(response);
  return outputResult.sanitizedText;
} else {
  console.log('Threat detected:', inputResult.threats);
  return 'Request blocked for security reasons.';
}

Input Scanners

Input scanners analyze user prompts before they reach the LLM. Available scanners include:

🛡️
Prompt Injection
Detects direct and indirect prompt injection attempts
🔐
PII Scanner
Identifies and masks personally identifiable information
🔑
Secrets Scanner
Detects API keys, passwords, and credentials in input
⚠️
Toxicity Filter
Filters harmful, inappropriate, or toxic content

Output Scanners

Output scanners inspect LLM responses before they reach the end user, preventing data leakage and ensuring content quality.

Custom Rules

Define custom security rules using our rule engine:

guard.addRule({
  name: 'block-competitor-mentions',
  type: 'output',
  pattern: /competitor_name/gi,
  action: 'redact',
  replacement: '[REDACTED]'
});

REST API

Use the REST API directly if you prefer HTTP calls over the SDK:

POST https://api.llmguardpro.com/v1/scan

Headers:
  Authorization: Bearer lgp_sk_...
  Content-Type: application/json

Body:
{
  "text": "User prompt to scan",
  "direction": "input",
  "scanners": ["prompt_injection", "pii"]
}

Webhooks

Configure webhooks to receive real-time notifications when threats are detected. Set up webhook endpoints in your dashboard settings.