--- id: guardrails-ai version: "0.11.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # guardrails-ai — Adding guardrails to large language models. License: permissive · Maintenance: active · Downloads: 158.5K/mo ## What it is and what it does Guardrails is a validation and safety framework for large language model applications. It provides two main capabilities: running configurable Input/Output Guards that detect and mitigate specific types of risks (using pre-built validators from Guardrails Hub), and generating structured data from LLMs by enforcing Pydantic schemas through either function calling or prompt optimization. The framework works by composing multiple validators into Guards that intercept LLM inputs and outputs. It supports both direct Python usage and a standalone server mode (via Flask) that exposes a REST API. It integrates with popular LLM clients like OpenAI and supports custom validators. The dependency tree includes langchain-core, openai, litellm, pydantic, and observability tools (OpenTelemetry), making it suitable for production LLM pipelines. Use it for: - Validate LLM outputs against regex patterns, schema constraints, or custom business rules before returning to users. - Detect and block toxic language, competitor mentions, or other harmful content in LLM responses. - Generate structured JSON or Pydantic models from LLM outputs with guaranteed schema compliance. - Run a standalone Guardrails service that multiple applications can call via REST API for centralized LLM validation. - Combine multiple validators (e.g., toxic language + competitor detection) into a single Guard for multi-layer risk mitigation. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Guardrails is a Python framework that validates and constrains LLM inputs and outputs by running configurable guards, and helps generate structured data from language models. Yes. Guardrails addresses a real need in LLM applications—validating and constraining model outputs—with a mature, actively maintained framework. Low install friction, permissive licensing, and no known vulnerabilities make it a safe choice. Install if you need input/output validation, structured data extraction, or risk detection in LLM pipelines; the extensive dependency tree is justified by its integration with standard LLM tooling. ## Install pip install guardrails-ai uv add guardrails-ai poetry add guardrails-ai ## Installing guardrails-ai Before you install: Low install friction with a pure-Python wheel. Active maintenance with a recent release. Depends on 27 runtime packages including langchain-core, openai, litellm, and pydantic, which are standard in LLM applications. License in practice: Apache-2.0 permissive license allows commercial use, modification, and distribution with minimal restrictions. Quickstart: pip install guardrails-ai from guardrails import Guard, OnFailAction from guardrails_ai.regex_match import RegexMatch guard = Guard().use( RegexMatch, regex="\\(?\\d{3}\\)?-? *\\d{3}-? *-?\\d{4}", on_fail=OnFailAction.EXCEPTION ) guard.validate("123-456-7890") Requires Python 3.10 or later. Additional guardrail validators must be installed separately from Guardrails Hub (e.g., guardrails-ai-regex-match). Verify before relying: - Performance and latency characteristics of the 24 guardrails mentioned in the Guardrails Index benchmark. - Whether the Guardrails Server (Flask-based) is production-ready or requires Docker/Gunicorn for all deployments. - Compatibility and integration depth with specific LLM providers beyond those listed in dependencies. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 158.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags llm input output validation, structured data from language models, guardrails for ai safety, llm risk detection mitigation, pydantic schema enforcement llm, llm-safety, validation-framework, structured-output [View on SkillFed](https://skillfed.io/packages/guardrails-ai) · [View on PyPI](https://pypi.org/project/guardrails-ai/)