Knowledge Base Regulation Tracker Standards & Frameworks OSS Directory AI Incident Database Research Paper Library Case Studies Society Articles News Jobs About Charter Sign inBecome a Member

LLM Guard

Input and output guardrails

Security toolkit for LLM interactions with input scanners (prompt injection, secrets, PII anonymisation, toxicity, banned topics) and output scanners (relevance, sensitive data, malicious URLs, bias), as a library or API. Archived on GitHub in 2026 after Protect AI joined Palo Alto Networks; still widely deployed.

guardrailsprompt injectionpiisecrets

LLM Guard: Security Toolkit for LLM Interactions

LLM Guard is an open-source security toolkit developed by Protect AI to secure interactions with Large Language Models (LLMs). It provides runtime defense mechanisms through input and output scanners, ensuring safe and compliant LLM deployments. Originally archived in 2026 after Protect AI joined Palo Alto Networks, the tool remains widely deployed in production environments.

The toolkit is designed for seamless integration into existing systems, offering both library and API-based deployment options. It operates under the permissive MIT license and is implemented in Python, requiring Python 3.9 or higher for full functionality.

Installation is straightforward via pip, with base dependencies automatically managed. Advanced features may introduce additional library requirements, which are installed dynamically as needed. Users are encouraged to upgrade pip to avoid potential installation issues.

Input and Output Scanners for Comprehensive Security

LLM Guard employs a modular scanner architecture to detect and mitigate risks at both input and output stages of LLM interactions. Input scanners focus on sanitizing prompts, preventing malicious or unauthorized requests, while output scanners ensure responses adhere to security, compliance, and quality standards.

Input Scanners

  • Anonymize: Detects and masks personally identifiable information (PII) in prompts to prevent data leakage.
  • BanCode: Blocks prompts containing executable or sensitive code snippets.
  • BanCompetitors: Filters prompts referencing competing products or services.
  • BanSubstrings: Removes predefined substrings deemed unsafe or policy-violating.
  • BanTopics: Restricts prompts on predefined sensitive or off-limit topics.
  • Gibberish: Identifies nonsensical or malformed input to prevent abuse.
  • InvisibleText: Detects hidden or obfuscated text in prompts.
  • Language: Ensures prompts are in supported languages to avoid misinterpretation.
  • PromptInjection: Mitigates prompt injection attacks by analyzing intent and structure.
  • Regex: Applies custom regex patterns to enforce input constraints.
  • Secrets: Flags prompts containing API keys, passwords, or other sensitive credentials.
  • Sentiment: Assesses emotional tone to prevent toxic or manipulative prompts.
  • TokenLimit: Enforces maximum token limits to prevent excessive resource usage.
  • Toxicity: Detects harmful, offensive, or abusive language in prompts.

Output Scanners

  • BanCode: Prevents responses containing executable or sensitive code.
  • BanCompetitors: Filters responses referencing competing products or services.
  • BanSubstrings: Removes predefined unsafe or policy-violating substrings from responses.
  • BanTopics: Restricts responses on predefined sensitive or off-limit topics.
  • Code: Validates code snippets in responses for security and correctness.
  • Language: Verifies response language consistency with user input.
  • LanguageSame: Confirms responses maintain the same language as the prompt.
  • MaliciousURLs: Blocks or flags URLs linked to phishing or malicious sites.
  • NoRefusal: Prevents responses that enable harmful or unethical requests.
  • Gibberish: Identifies nonsensical or incoherent responses.
  • Regex: Applies custom regex patterns to enforce output constraints.
  • Sensitive: Flags responses containing sensitive or confidential information.
  • Sentiment: Assesses emotional tone to maintain professionalism in responses.
  • Toxicity: Detects harmful, offensive, or abusive language in outputs.
  • URLReachability: Verifies the accessibility and safety of embedded URLs.

Deployment and Community Support

LLM Guard is optimized for production environments, with documentation and examples provided for integration with platforms like ChatGPT and as a standalone API.

  • Users can join a dedicated Slack channel for discussions, troubleshooting, and feedback.
  • Production support is available via email for deployment-specific assistance.

Sources

Contribute

Spot an error, or know a record we should add? Members can propose additions and submit corrections.