# LLM Guard

> Open-source Python toolkit from Protect AI that scans LLM prompts and outputs for security risks such as prompt injection and data leakage.

LLM Guard is an open-source Python security toolkit from Protect AI for sanitizing and checking interactions with large language models. It offers input and output scanners that cover harmful language, data leakage, and prompt injection. The GitHub repository is marked as archived, and the README states the project and its associated Hugging Face models are no longer under active development or maintained.

## What It Is

LLM Guard sits between an application and an LLM. Prompts pass through input scanners before reaching the model, and model responses pass through output scanners before being returned. It installs with pip and requires Python 3.9 or higher. It can also be deployed as an API.

## Scanner Coverage

Input scanners include Anonymize, BanCode, BanCompetitors, BanSubstrings, BanTopics, Code, Gibberish, InvisibleText, Language, PromptInjection, Regex, Secrets, Sentiment, TokenLimit and Toxicity. Output scanners include Bias, Deanonymize, FactualConsistency, JSON, MaliciousURLs, NoRefusal, ReadingTime, Relevance, Sensitive, URLReachability and others. Custom scanners can be added through the documented customization guide.

## Integration Tutorials

The documentation includes tutorials for the OpenAI SDK, LiteLLM across 100+ LLMs, LangChain, and retrieval-augmented generation with LangChain and LlamaIndex. It also covers secure agents with LangChain, loading models from disk, and optimization. A hosted playground on Hugging Face lets users try the scanners.

## Current Status

The repository is archived and carries an explicit notice that the project is no longer actively developed or maintained. It is released under the MIT license.

## Features
- Input scanners for prompt injection, secrets, toxicity, invisible text, and more
- Output scanners for sensitive data, malicious URLs, bias, and factual consistency
- Anonymize and deanonymize sensitive data
- Deployable as an API
- Custom scanner support
- Hosted playground
- Tutorials for secure RAG and agents

## Integrations
OpenAI SDK, LiteLLM, LangChain, LlamaIndex, Hugging Face

## Platforms
DEVELOPER_SDK, API

## Pricing
Open Source

## Links
- Website: https://protectai.github.io/llm-guard/
- Documentation: https://protectai.github.io/llm-guard/
- Repository: https://github.com/protectai/llm-guard
- EveryDev.ai: https://www.everydev.ai/tools/llm-guard
