Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Guardrails ai Guardrails Create Command Server

From Leeroopedia
Knowledge Sources
Domains Deployment, Configuration
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete CLI command for generating server-ready Guard configurations provided by the guardrails package.

Description

This is the same create_command function as used for Hub submission scaffolding, but documented from the server deployment perspective. The generated config.py is intended to be loaded by guardrails start --config to register Guards as server endpoints. The command installs specified validators, generates imports and Guard initialization code, and outputs a customizable config file.

Usage

Run guardrails create with validators and a guard name, then use the generated file with guardrails start --config.

Code Reference

Source Location

  • Repository: guardrails
  • File: guardrails/cli/create.py
  • Lines: L18-104

Signature

@gr_cli.command(name="create")
def create_command(
    validators: Optional[str] = typer.Option(default=""),
    guard_name: Optional[str] = typer.Option(default=None),
    local_models: Optional[bool] = typer.Option(None),
    filepath: str = typer.Option(default="config.py"),
    template: Optional[str] = typer.Option(default=None),
    dry_run: bool = typer.Option(default=False, is_flag=True),
):

Import

# CLI command:
# guardrails create --validators "..." --guard-name "..."

I/O Contract

Inputs

Name Type Required Description
validators str Yes Comma-separated Hub URIs for the server's Guards
guard_name Optional[str] No Name for the Guard (used as endpoint name)
filepath str No Output path (default "config.py")

Outputs

Name Type Description
config.py File Server configuration with Guard definitions for use with guardrails start

Usage Examples

Server Config Generation

# Generate server config
guardrails create \
    --validators "hub://guardrails/regex_match,hub://guardrails/toxic_language" \
    --guard-name ContentGuard

# Start the server with the config
guardrails start --config config.py

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment