input_schema to validate dictionaries automatically.
Passing Pydantic Models Directly
Pass a Pydantic model instance toinput:
ValidationError before the agent runs.
Using input_schema
Setinput_schema on the agent to validate dictionaries automatically:
Validation Errors
Invalid input raises a PydanticValidationError:
When to Use Each Approach
| Approach | Use when |
|---|---|
| Pass model directly | You’re building the input in code |
Use input_schema | Input comes from external sources (APIs, files, user input) |
Common Patterns
API Request Handler
Configuration-Driven Tasks
Nested Models
Related
- Team Structured Input: Configure structured input for teams
- Structured Output: Get validated output from agents