LLM Guard
FrameworkFreeOpen-source LLM input/output security scanner toolkit.
Capabilities15 decomposed
dual-gate prompt and output scanning with unified scanner interface
Medium confidenceImplements a modular scanner framework where both input (pre-LLM) and output (post-LLM) validators follow a common interface returning (sanitized_text, is_valid, risk_score) tuples. Scanners are composed independently and can be chained in arbitrary order, enabling flexible security pipelines. The architecture decouples scanner logic from orchestration, allowing developers to enable/disable scanners via configuration without code changes.
Unified scanner interface (scan() method returning triplet) across 36+ independent scanners (15 input, 21 output) allows arbitrary composition without coupling; architecture prioritizes modularity and configuration-driven behavior over monolithic validation logic
More granular and composable than monolithic content filters; unlike generic ML-based content moderation APIs, LLM Guard provides specialized scanners for LLM-specific threats (prompt injection, token smuggling) with local execution and no external API dependencies
prompt injection detection via multiple pattern and semantic approaches
Medium confidenceDetects prompt injection attacks using a multi-strategy approach combining regex-based pattern matching for known injection signatures, semantic similarity analysis against injection templates, and structural analysis of prompt delimiters and role-switching patterns. The scanner identifies attempts to override system instructions, inject new directives, or manipulate LLM behavior through adversarial prompt crafting.
Combines regex pattern matching for known injection signatures with semantic similarity scoring against injection templates and structural analysis of delimiter patterns; uses local embedding models rather than external APIs, enabling offline detection without cloud dependencies
More specialized for LLM-specific injection vectors than generic input validation; faster than API-based detection services because it runs locally; more comprehensive than simple keyword filtering by combining multiple detection strategies
onnx model optimization for low-latency and resource-constrained deployment
Medium confidenceSupports ONNX (Open Neural Network Exchange) optimization for transformer-based scanners, enabling faster inference and reduced memory footprint. Converts HuggingFace models to ONNX format with quantization options (int8, float16), enabling deployment on CPU-only or edge devices. Configuration-driven ONNX enablement allows switching between full-precision and optimized models without code changes. Reduces model inference latency by 2-10x compared to PyTorch, enabling real-time scanning in latency-sensitive applications.
Provides configuration-driven ONNX optimization with quantization support (int8, float16) enabling 2-10x latency reduction; supports switching between full-precision and optimized models via configuration without code changes; enables deployment on CPU-only and edge devices where GPU acceleration is unavailable
Faster inference than PyTorch models because ONNX Runtime is optimized for inference; more flexible than fixed-optimization approaches because quantization level is configurable; enables deployment scenarios (edge, serverless, CPU-only) that would be infeasible with full-precision models
configurable scanner composition and policy-driven security pipelines
Medium confidenceEnables developers to compose scanners into custom security pipelines via configuration files (YAML) or code, selecting which scanners to enable, their order, and their parameters. Supports conditional scanner execution (e.g., run PII scanner only if prompt contains certain keywords), scanner chaining (output of one scanner feeds into next), and policy-driven behavior (different scanner sets for different user roles or risk profiles). Eliminates need to write custom orchestration code for complex security workflows.
Supports configuration-driven scanner composition via YAML or code, enabling policy-driven security pipelines without custom orchestration code; supports conditional scanner execution and chaining, enabling complex security workflows; enables different policies per deployment/user without code changes
More flexible than hardcoded scanner sequences because policies are configuration-driven; more maintainable than custom orchestration code because logic is declarative; enables non-developers to modify security policies via configuration files
observability and audit logging for security scanning decisions
Medium confidenceProvides hooks for logging and monitoring all scanning decisions, enabling compliance auditing and security analysis. Integrates with standard Python logging framework and supports custom observability backends. Logs include scanner name, input text, risk score, sanitization actions, and decision (allow/block). Enables teams to audit security decisions, identify patterns in attacks, and monitor scanner performance. Supports structured logging (JSON) for integration with log aggregation systems (ELK, Datadog, Splunk).
Integrates with Python logging framework enabling flexible log destination configuration; supports structured logging (JSON) for log aggregation systems; provides detailed audit trail of all scanning decisions including risk scores and sanitization actions
More flexible than hardcoded logging because it integrates with Python logging framework; more comprehensive than simple decision logging because it includes risk scores and scanner details; enables compliance auditing and attack pattern analysis
batch scanning with multi-text processing
Medium confidenceSupports scanning multiple prompts or outputs in a single API call, enabling efficient batch processing for high-throughput scenarios. Processes batches through the scanner pipeline with optimized tensor operations and optional parallelization, reducing per-item overhead compared to individual requests.
Supports batch processing of multiple texts through the scanner pipeline with optimized tensor operations, reducing per-item overhead compared to individual scans. Enables efficient processing of large datasets without requiring separate API calls per text.
More efficient than individual scans because it amortizes model loading and tokenization overhead across multiple texts; more flexible than fixed batch sizes because batch size is configurable.
risk score aggregation and policy-based decision making
Medium confidenceAggregates risk scores from multiple scanners using configurable strategies (weighted sum, maximum, AND/OR logic) to produce a final security decision. Enables policy-based rules (e.g., 'block if any scanner scores > 0.8 OR toxicity > 0.9') for nuanced security decisions beyond binary allow/block.
Provides configurable risk score aggregation with policy-based decision rules, enabling organizations to define nuanced security policies that weight different threats differently. Supports multiple aggregation strategies (weighted sum, maximum, AND/OR logic) for flexible policy expression.
More flexible than binary scanners because it enables nuanced decisions based on risk scores; more maintainable than hardcoded logic because policies are declarative and configurable.
pii detection and anonymization with stateful vault storage
Medium confidenceDetects personally identifiable information (names, emails, phone numbers, SSNs, credit cards, etc.) in prompts and outputs using pattern matching and NER (Named Entity Recognition) models. Detected PII can be anonymized by replacing with tokens and storing original values in a stateful Vault object, enabling later de-anonymization. The Vault class maintains in-memory or persistent storage of PII mappings, supporting workflows where sensitive data must be redacted from LLM context but recovered in responses.
Integrates stateful Vault class for PII storage and recovery, enabling reversible anonymization workflows; combines regex pattern matching for structured PII (SSN, credit card) with NER models for unstructured PII (names, organizations), supporting both detection and remediation in a single component
More comprehensive than simple regex-based PII detection because it includes NER for context-aware entity recognition; unlike external PII masking services, runs locally with no API calls, enabling offline operation and compliance with data residency requirements; Vault system enables de-anonymization, supporting workflows where original values must be recovered
toxic content and harmful language detection with configurable severity thresholds
Medium confidenceDetects toxic, abusive, and harmful language in prompts and outputs using transformer-based text classification models trained on toxicity datasets. Scanners classify text into categories (profanity, insults, threats, harassment) and assign risk scores. Developers can configure severity thresholds to reject or flag content based on risk tolerance, enabling fine-grained control over what language is permitted in different contexts.
Uses transformer-based text classification models (not regex or keyword lists) for context-aware toxicity detection; supports configurable severity thresholds allowing different risk tolerances per deployment; runs locally without external moderation APIs, enabling real-time detection with no latency from API calls
More accurate than keyword-based filtering because it understands context and semantic meaning; faster than external moderation APIs (Perspective API, AWS Comprehend) because it runs locally; more flexible than binary allow/block because it provides risk scores enabling threshold-based policies
sensitive topic and banned content filtering with custom policy configuration
Medium confidenceDetects and filters prompts/outputs containing banned topics or sensitive subjects (e.g., violence, self-harm, illegal activities, adult content) based on configurable policy lists. Uses semantic similarity matching against topic keywords and phrases to identify content violating organizational policies. Developers can define custom banned topic lists per deployment, enabling different policies for different user segments or jurisdictions.
Supports custom, configurable banned topic lists enabling organization-specific policies; uses semantic similarity matching (not keyword matching) to detect topic discussions even with paraphrasing; allows per-deployment or per-user-segment policy configuration without code changes
More flexible than hardcoded content filters because policies are configuration-driven; more accurate than keyword matching because semantic similarity detects paraphrased discussions of banned topics; enables multi-tenant deployments with different policies per customer
code injection and malicious code detection in prompts and outputs
Medium confidenceDetects attempts to inject executable code (SQL, shell commands, Python, JavaScript) into prompts or malicious code in LLM outputs. Uses pattern matching for common injection signatures (SQL keywords, shell metacharacters), AST parsing for code structure analysis, and optional semantic analysis to identify code-like patterns. Prevents LLM from being used to generate or execute malicious code, and blocks prompts attempting to manipulate backend systems through code injection.
Combines regex pattern matching for injection signatures with AST parsing for code structure analysis; detects code-like patterns in both prompts and outputs; supports multiple programming languages and injection types (SQL, shell, Python, JavaScript) in a single scanner
More comprehensive than simple keyword filtering because it understands code structure via AST parsing; more targeted than generic malware detection because it focuses on injection patterns specific to LLM contexts; runs locally without external security scanning services
invisible unicode and encoding-based obfuscation detection
Medium confidenceDetects attempts to hide malicious content using invisible unicode characters, zero-width characters, homoglyph attacks, and other encoding-based obfuscation techniques. Analyzes character encodings to identify non-printable characters, combining marks, and lookalike characters that could bypass other security scanners or confuse users. Prevents attackers from using unicode tricks to inject prompts or hide malicious instructions in LLM outputs.
Specialized detection for unicode-based obfuscation techniques (zero-width characters, homoglyphs, combining marks) that other scanners may miss; analyzes character encodings at the unicode level rather than semantic level; prevents evasion of other security scanners through encoding tricks
More targeted than generic text sanitization because it specifically detects obfuscation patterns; complements other scanners by catching evasion attempts that use unicode tricks; runs locally with no external dependencies
token length validation and context window management
Medium confidenceValidates that prompts and outputs fit within LLM context windows by tokenizing text using language-specific tokenizers (HuggingFace, OpenAI, Anthropic). Calculates token counts for prompts and outputs, enforces maximum token limits, and provides warnings when approaching context window limits. Integrates with multiple tokenizer backends, enabling accurate token counting for different LLM providers without sending data to external APIs.
Supports multiple tokenizer backends (HuggingFace, OpenAI, Anthropic) enabling accurate token counting for different LLM providers; runs tokenization locally without API calls, enabling offline validation; integrates with LLM Guard's scanner framework for seamless token validation in security pipelines
More accurate than character-count approximations because it uses actual tokenizers; faster than API-based token counting because it runs locally; supports multiple LLM providers in single codebase, enabling multi-provider applications
rest api service for remote scanner deployment and orchestration
Medium confidenceExposes LLM Guard scanners via FastAPI HTTP endpoints, enabling remote deployment of security scanning as a microservice. The API service (llm-guard-api) wraps scanner implementations with REST endpoints for prompt validation, output validation, and batch scanning. Supports configuration-driven scanner selection via YAML, Docker deployment with GPU acceleration, and observability hooks for logging and monitoring. Enables teams to deploy scanning infrastructure separately from application code.
Wraps modular scanner framework in FastAPI service with configuration-driven scanner selection; provides Docker images with optional GPU support (CUDA) for accelerated model inference; enables language-agnostic access to LLM Guard scanners via HTTP, decoupling scanning infrastructure from application code
More flexible than embedding scanners in application code because scanning can be updated/scaled independently; supports GPU acceleration for high-throughput environments; enables polyglot deployments where scanning service is called from multiple languages/frameworks
litellm integration for transparent scanner injection into llm calls
Medium confidenceProvides native integration with LiteLLM proxy, enabling automatic injection of LLM Guard scanners into LLM API calls without modifying application code. Scanners run transparently before prompts reach the LLM and after responses are generated, implementing the dual-gate security model. Configuration-driven scanner selection allows different scanning policies per model, provider, or user without code changes. Supports all LiteLLM-compatible providers (OpenAI, Anthropic, Ollama, etc.).
Integrates with LiteLLM proxy layer enabling transparent scanner injection without application code changes; supports configuration-driven per-model/provider scanning policies; works with all LiteLLM-compatible providers (OpenAI, Anthropic, Ollama, Azure, etc.) in unified framework
More transparent than manual scanner calls because it integrates at LiteLLM middleware layer; more flexible than provider-specific security solutions because it works across all LiteLLM providers; enables security-by-default without requiring developers to remember to call scanners
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with LLM Guard, ranked by overlap. Discovered automatically through the match graph.
Prompt Guard
Meta's prompt injection and jailbreak detection classifier.
Rebuff
Self-hardening prompt injection detector with multi-layer defense.
Llama Guard 3
Meta's safety classifier for LLM content moderation.
promptscan
Production-ready prompt injection detection for AI agents. Scan user input, retrieved docs, and tool outputs before passing them to an LLM. Returns injection_detected, score, attack_type, and sanitized text.
PromptEnhancer
[CVPR 2026] PromptEnhancer is a prompt-rewriting tool, refining prompts into clearer, structured versions for better image generation.
Lakera Guard
Real-time prompt injection and LLM threat detection API.
Best For
- ✓teams building LLM applications requiring defense-in-depth security
- ✓developers integrating LLM Guard into existing LLM pipelines (LiteLLM, LangChain)
- ✓security-conscious organizations needing configurable, auditable scanning policies
- ✓developers building user-facing LLM chatbots or assistants
- ✓teams deploying LLMs in multi-tenant environments where prompt injection is a primary threat
- ✓security teams needing to audit and log injection attempts for compliance
- ✓teams deploying on cost-constrained infrastructure (CPU-only servers, edge devices)
- ✓applications with strict latency requirements (<100ms per request)
Known Limitations
- ⚠Scanner composition adds latency per chain step (no batching optimization across scanners)
- ⚠Risk scores are scanner-specific and not normalized across different scanner types
- ⚠No built-in persistence for scan results — requires external logging/monitoring integration
- ⚠Scanners execute sequentially; no parallel execution optimization for independent scanners
- ⚠Pattern-based detection can be evaded by obfuscation or novel injection techniques not in signature database
- ⚠Semantic detection requires embedding models which add ~50-200ms latency per scan
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
About
Open-source toolkit for securing LLM interactions with both input and output scanners. Detects prompt injection, toxicity, ban topics, code injection, sensitive data, and invisible unicode characters across 15+ scanner types.
Categories
Alternatives to LLM Guard
AWS AI coding assistant — code generation, AWS expertise, security scanning, code transformation agent.
Compare →Are you the builder of LLM Guard?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →