Repolode
guardrails-ai

guardrails-ai/guardrails

A Python framework that adds input and output guards to LLM applications and generates validated structured data from LLM outputs.

Stars
7,540
Forks
727
Open issues
74
Last commit
6 days ago

What is it?

Guardrails is a Python framework for making LLM-based applications more reliable. It runs input and output guards that detect, quantify and mitigate specific risks, built from validators that can be combined into a single guard. Validators are distributed through Guardrails Hub, and each can be installed as a separate package with pip.

The framework also helps generate structured data from LLMs. You define the expected output as a Pydantic model, and Guardrails produces output matching that schema, using function calling where the model supports it and schema-in-prompt instructions where it does not.

Guardrails can run as a standalone Flask service exposing a REST API, and it offers an OpenAI-compatible endpoint so existing OpenAI SDK clients can route calls through guards. The project is licensed under Apache-2.0.

Key features

  • 01Input and output guards that check LLM inputs and responses against configurable validators.
  • 02Pre-built validators from Guardrails Hub, such as regex matching, competitor checks and toxic language detection.
  • 03Structured data generation from LLMs using Pydantic models.
  • 04Function calling and prompt-based schema instructions for different model capabilities.
  • 05Standalone server with a REST API and an OpenAI-compatible endpoint.

Use cases

  • Filtering toxic or off-topic content in a chatbot before it reaches users.
  • Preventing an assistant from naming competitors or leaking restricted information.
  • Getting LLM responses in a fixed JSON structure for downstream code.
  • Adding a validation layer to an existing OpenAI-based application without rewriting client code.

Quick start

  1. 1

    Install the guardrails-ai package

    pip install guardrails-ai
  2. 2

    Configure the Guardrails Hub CLI

    guardrails configure
  3. 3

    Install a validator from Guardrails Hub

    pip install guardrails-ai-regex-match
  4. 4

    Create a Guard with the installed validator and run it, as shown in the README

Things to know

  • Guardrails is discontinuing its hosted remote inferencing, with a planned cutoff on August 25, 2026.
  • Validators are moving to separate PyPI packages that must be installed individually.

Topics

FAQ

What is guardrails?
A Python framework that adds input and output guards to LLM applications and generates validated structured data from LLM outputs. Guardrails is a Python framework for making LLM-based applications more reliable. It runs input and output guards that detect, quantify and mitigate specific risks, built from validators that can be combined into a single guard. Validators are distributed through Guardrails Hub, and each can be installed as a separate package with pip.
Is guardrails free to use? What license does it have?
guardrails is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is guardrails still maintained?
Actively maintained. The last commit to guardrails was on Oct 15, 2026.
What can I use guardrails for?
Filtering toxic or off-topic content in a chatbot before it reaches users. Preventing an assistant from naming competitors or leaking restricted information. Getting LLM responses in a fixed JSON structure for downstream code. Adding a validation layer to an existing OpenAI-based application without rewriting client code.
How do I install guardrails?
Install the guardrails-ai package: pip install guardrails-ai Configure the Guardrails Hub CLI: guardrails configure Install a validator from Guardrails Hub: pip install guardrails-ai-regex-match Create a Guard with the installed validator and run it, as shown in the README
Where can I get guardrails?
The source code and installation instructions are on GitHub: https://github.com/guardrails-ai/guardrails

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects