Quick Start
1
Install Package
First, install the PraisonAI Agents package:
2
Set API Key
Set your OpenAI API key and EXA API key as environment variables in your terminal:
3
Create a file
Create a new file
app.py with the basic setup:4
Start Agents
Type this in your terminal to run your agents:
Requirements
- Python 3.10 or higher
- OpenAI API key. Generate OpenAI API key here
- EXA API key for search functionality
- Basic understanding of Python and Pydantic
Understanding Tools as Class
What are Class-based Tools?
Class-based tools enable:
- Custom functionality encapsulation
- Reusable tool components
- Type-safe tool interfaces
- Complex API integrations
Features
Pydantic Integration
Built-in validation and type safety with Pydantic models.
API Wrapping
Easily wrap external APIs as agent tools.
Method Flexibility
Support for multiple methods within a single tool.
Type Hints
Strong typing for better code reliability.
Configuration Options
Troubleshooting
Tool Issues
If tool execution fails:
- Check API credentials
- Verify network connectivity
- Enable verbose logging
Type Errors
If type validation fails:
- Review input types
- Check Pydantic model
- Verify method signatures
Next Steps
Function Tools
Learn about function-based tools
API Tools
Explore API integration tools
For optimal results, ensure your tool classes are well-documented and follow Pydantic best practices for model definition.
Best Practices
Keep tools focused on one task
Keep tools focused on one task
Each tool should do one thing well - this makes agent behavior more predictable.
Return descriptive strings
Return descriptive strings
Return human-readable strings from tools so the agent can understand and relay results.
Include error messages in returns
Include error messages in returns
On failure, return a descriptive error string rather than raising an exception.
Add docstrings to tools
Add docstrings to tools
The agent uses tool docstrings to decide when to call a tool - write clear, specific descriptions.
Related
Custom Tools
Build your own agent tools
Tools Overview
Browse PraisonAI tool documentation

