Add a toxicity or competitor-mention check to a chatbot so flagged responses trigger an error before reaching users.
Force an AI model to return a structured Python object with specific fields instead of free-form text.
Run Guardrails as a standalone server so multiple services share one validation layer through a standard web API.
Browse Guardrails Hub to install pre-built validators for phone number format, PII detection, or hallucination checks.
Guardrails is a Python library for adding safety and structure checks to applications that use AI language models. When you build something on top of a large language model, the model's output is not guaranteed to be safe, accurate, or formatted in any particular way. Guardrails sits in the middle and checks what goes in and what comes out, raising an error or taking another action when something looks wrong. The library has two main uses. The first is validation: you define rules that the model's output must pass, such as checking for toxic language, detecting whether the model mentions a competitor's name, or confirming that a phone number matches the right format. These rules are called validators and can be combined into a "Guard" object that checks each response. Guardrails Hub is an accompanying catalog where you can browse and install pre-built validators for dozens of common scenarios. The second use is structured output: instead of getting back a block of plain text from the model, you tell Guardrails the exact data shape you want (using Python data classes), and it prompts the model to produce output that fits that structure. For models that support it, this works through a function-calling mechanism. For models that do not, Guardrails adjusts the prompt to describe the expected format. Guardrails can also run as a standalone server using a built-in command. Once running, other parts of your application can talk to it over a standard web API, including using the same client library that the OpenAI SDK uses. This makes it possible to add Guardrails to an existing project without changing much of the surrounding code. The project is open source under the Apache 2.0 license and installable via pip. A hosted documentation site, a Discord community, and a benchmark index comparing validator performance across common risk categories are available at guardrailsai.com.
← guardrails-ai on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.