Practical overview
When it fits
Use Guardrails when building a Python LLM application that needs selected checks around model interactions or a defined structure for generated responses.
Who it is for
- Python developers building applications that use large language models.
- Teams that need to validate model inputs or outputs with selected validators.
- Developers who want LLM responses shaped to a Pydantic data model.
Documented uses
- Add a configurable validation layer around LLM inputs and outputs.
- Combine validators to detect specified conditions in text and define how validation failures are handled.
- Shape model responses to a defined structured-data model.
Requirements & limits
The repository is public and identifies the project as Apache-2.0 licensed. The README documents installation through pip.
- The core workflow is Python-based and involves installing the library and any required validator packages.
- Validators are selected and combined into guards, so the checks depend on the validators chosen for the application.
- Structured-output setup uses a Pydantic model; the README describes function calling for models that support it.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install the Guardrails library and configure a validator
Set up the Python package, install a documented validator, and create a guard that validates text against a regular expression.
Before you start
- Python environment with pip
- Access to install the Guardrails package and a validator package
Steps
Install the library with the command below.
pip install guardrails-aiRun
guardrails configureto configure the Guardrails Hub CLI.Install the regex validator with the command below.
pip install guardrails-ai-regex-matchCreate a Guard using
RegexMatchand callguard.validate()on text.
Expected outcome
A configured guard validates text against the chosen regular expression and can raise an exception when validation fails.
Guide limitations
- The example validates a specific phone-number pattern; it does not establish that the pattern is appropriate for every application.
- The example shows validation behavior, not integration with a particular production model or deployment.
Define a structured output shape for an LLM response
Create a Pydantic model and use it as the structure for a Guard that formats LLM output.
Before you start
- Python environment
- Pydantic
- An LLM interaction supported by the chosen approach
Steps
Define a Pydantic
BaseModelwith the fields required in the response.Create a Guard from that model.
Use the Guard in the LLM interaction to request output formatted to the model.
Expected outcome
The Guard is configured to shape the model response according to the defined data structure.
Guide limitations
- It describes function calling for models that support it and does not specify the alternative method in the available instructions.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 7 October 2026
- Original website title
- guardrails-ai/guardrails · Official homepage title · retained in its source language

