Implementation:Guardrails ai Guardrails Configure CLI
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Configuration, CLI |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Concrete CLI command for initializing Guardrails credentials and preferences provided by the guardrails package.
Description
The configure command is a Typer-based CLI command that prompts the user for or accepts Hub API tokens, metrics collection preferences, and remote inferencing settings. It writes these to a ~/.guardrailsrc file and validates the token against the Hub authentication service.
Usage
Run this command when setting up Guardrails for the first time, or when you need to update your Hub API key or change metrics/inference preferences.
Code Reference
Source Location
- Repository: guardrails
- File: guardrails/cli/configure.py
- Lines: L57-140
Signature
@guardrails.command()
def configure(
enable_metrics: Optional[bool] = typer.Option(
True,
"--enable-metrics/--disable-metrics",
help="Opt out of anonymous metrics collection.",
prompt="Enable anonymous metrics reporting?",
),
token: Optional[str] = typer.Option(
None,
"--token",
help="API Key for Guardrails.",
),
remote_inferencing: Optional[bool] = typer.Option(
True,
"--enable-remote-inferencing/--disable-remote-inferencing",
help="Opt in to remote inferencing.",
prompt="Do you wish to use remote inferencing?",
),
clear_token: Optional[bool] = typer.Option(
False,
"--clear-token",
help="Clear the existing token from the configuration file.",
),
):
Import
# CLI command - invoked via shell:
# guardrails configure
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| enable_metrics | Optional[bool] | No | Opt in/out of anonymous metrics collection (default True) |
| token | Optional[str] | No | API Key for Guardrails Hub |
| remote_inferencing | Optional[bool] | No | Enable remote ML inference for validators (default True) |
| clear_token | Optional[bool] | No | Clear existing token from configuration file |
Outputs
| Name | Type | Description |
|---|---|---|
| ~/.guardrailsrc | File | Configuration file with id, token, enable_metrics, use_remote_inferencing |
| settings singleton | Settings | Updated global settings singleton with new configuration |
Usage Examples
Interactive Configuration
# Run with interactive prompts
guardrails configure
# Non-interactive with flags
guardrails configure --token "my-api-key" --enable-metrics --enable-remote-inferencing
Clear Token
# Clear stored token
guardrails configure --clear-token
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment