Skip to content

accuknox/llm-guard

 
 

Repository files navigation

LLM Guard - The Security Toolkit for LLM Interactions

LLM Guard by Protect AI is a comprehensive tool designed to fortify the security of Large Language Models (LLMs).

Documentation | Playground | Changelog

GitHub stars MIT license Code style: black PyPI - Python Version Downloads Downloads

Join Our Slack Community

What is LLM Guard?

LLM-Guard

By offering sanitization, detection of harmful language, prevention of data leakage, and resistance against prompt injection attacks, LLM-Guard ensures that your interactions with LLMs remain safe and secure.

Open-Source Guardrails for LLM & AI System Security

LLM Guard helps teams protect AI systems by enforcing security controls at the most vulnerable points of LLM usage:

  • Before model inference (input guardrails)
  • After model inference (output guardrails)
  • During execution and tool usage (runtime guardrails)

It is designed for production AI systems, not just experiments.

Why LLM Security Matters

Traditional application security tools are not designed for AI systems.

LLMs:

  • Accept untrusted natural language input
  • Produce non-deterministic outputs
  • Can leak sensitive data through responses
  • Can be manipulated to bypass policies at runtime

Without guardrails, LLM-powered systems introduce new attack surfaces that conventional security controls cannot detect or block.

LLM Threat Model

LLM Guard is built around real-world LLM security threats, including:

Common LLM Security Risks

  • Prompt Injection (direct and indirect)
  • Jailbreak attacks and role manipulation
  • Sensitive data leakage in responses
  • Training data exposure
  • Unauthorized tool or function execution
  • Policy and compliance violations at inference time

These risks exist even when models are hosted by trusted providers.

How LLM Guard Works

LLM Guard enforces security using layered guardrails:

Guardrail Layers

  • Input Guardrails
    Validate, sanitize, and assess prompts before they reach the model.

  • Output Guardrails
    Inspect model responses for sensitive data, policy violations, or unsafe content.

  • Runtime Guardrails
    Enforce security policies during execution, including tool calls and agent workflows.

Security Controls Covered

Control Type AI Layer Threats Mitigated
Input Validation Prompt Prompt injection, jailbreaks
Output Filtering Response Data leakage, unsafe outputs
Runtime Policies Execution Unauthorized actions, agent misuse
Governance Rules System Compliance and policy violations

Supported Use Cases

LLM Guard can be used to secure:

  • Enterprise chatbots
  • RAG (Retrieval-Augmented Generation) pipelines
  • AI agents and autonomous workflows
  • Internal AI assistants
  • Customer-facing generative AI applications

Installation

Begin your journey with LLM Guard by downloading the package:

pip install llm-guard

Getting Started

Important Notes:

  • LLM Guard is designed for easy integration and deployment in production environments. While it's ready to use out-of-the-box, please be informed that we're constantly improving and updating the repository.
  • Base functionality requires a limited number of libraries. As you explore more advanced features, necessary libraries will be automatically installed.
  • Ensure you're using Python version 3.9 or higher. Confirm with: python --version.
  • Library installation issues? Consider upgrading pip: python -m pip install --upgrade pip.

Examples:

Supported scanners

Prompt scanners

Output scanners

Community, Contributing, Docs & Support

LLM Guard is an open source solution. We are committed to a transparent development process and highly appreciate any contributions. Whether you are helping us fix bugs, propose new features, improve our documentation or spread the word, we would love to have you as part of our community.

  • Give us a ⭐️ github star ⭐️ on the top of this page to support what we're doing, it means a lot for open source projects!
  • Read our docs for more info about how to use and customize LLM Guard, and for step-by-step tutorials.
  • Post a Github Issue to submit a bug report, feature request, or suggest an improvement.
  • To contribute to the package, check out our contribution guidelines, and open a PR.

Join our Slack to give us feedback, connect with the maintainers and fellow users, ask questions, get help for package usage or contributions, or engage in discussions about LLM security!

Join Our Slack Community

Production Support

We're eager to provide personalized assistance when deploying your LLM Guard to a production environment.

About

The Security Toolkit for LLM Interactions

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.0%
  • Other 1.0%