Skip to main content
Handle user input safely with the Agent’s start() and chat() methods, plus optional guardrails for validation.

Quick Start

1

Basic Input with start()

2

Programmatic Input with chat()

3

CLI Input Loop

Input Methods

Guardrails

Use the guardrails parameter to validate agent outputs before returning:

Function-based Guardrail

LLM-based Guardrail

Guardrail Configuration Options

Structured Output Validation

Use Pydantic models to validate and structure agent outputs via the chat() method:

Input Sanitization

Sanitize user input before processing:

Advanced Topics

Prevent abuse with rate limiting:
Securely handle API keys:

Best Practices

Validate All Input

Never trust user input - validate type, format, and content

Use Guardrails

Add guardrails= for output validation and safety

Sanitize for Context

Different contexts need different sanitization (HTML, SQL, shell)

Rate Limit

Prevent abuse with request limits per user

API Reference

Agent Input Methods

Guardrails Parameter

Guardrails

Detailed guardrail configuration

Structured Output

Pydantic output validation

Tools

Tool input handling

Agents

Agent configuration