Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Guardrails ai Guardrails Start Server

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

Overview

Concrete CLI command for starting the Guardrails API development server provided by the guardrails package.

Description

The guardrails start command (start function) launches a local HTTP server. It first checks if guardrails-api is installed (auto-installing if missing), then delegates to guardrails_api.cli.start.start which runs the actual server. The server can be configured with a config file, port number, and environment variables.

Usage

Run guardrails start --config config.py to launch the development server.

Code Reference

Source Location

  • Repository: guardrails
  • File: guardrails/cli/start.py
  • Lines: L22-54

Signature

@guardrails.command()
def start(
    env: Optional[str] = typer.Option(
        default="", help="An env file to load environment variables from.",
    ),
    config: Optional[str] = typer.Option(
        default="", help="A config file to load Guards from.",
    ),
    port: Optional[int] = typer.Option(
        default=8000, help="The port to run the server on.",
    ),
    watch: bool = typer.Option(
        default=False, is_flag=True, help="Enable watch mode for logs.",
    ),
):

Import

# CLI command:
# guardrails start --config config.py --port 8000

I/O Contract

Inputs

Name Type Required Description
config Optional[str] No Path to config.py file defining Guards
port Optional[int] No Server port (default 8000)
env Optional[str] No Path to .env file for environment variables
watch bool No Enable live log tailing (default False)

Outputs

Name Type Description
HTTP server Process Running server at http://localhost:{port} with REST endpoints

Usage Examples

Start Development Server

# Basic start with config
guardrails start --config config.py

# Custom port with env file
guardrails start --config config.py --port 9000 --env .env

# With live log tailing
guardrails start --config config.py --watch

Related Pages

Implements Principle

Requires Environment

Page Connections

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