Skip to main content

Quick Start

Tools are functions that agents can use to interact with external systems and perform actions. They are essential for creating agents that can do more than just process text.

Creating Custom Tool

1
Create any function that you want to use as a tool, that performs a specific task.
2
Assign the tool to an agent

That's it!

You have created a custom tool and assigned it to an agent.

Implementing Tools Full Code Example

1

Install PraisonAI

Install the core package:
Terminal
2

Configure Environment

Terminal
Generate your OpenAI API key from OpenAI Use other LLM providers like Ollama, Anthropic, Groq, Google, etc. Please refer to the Models for more information.
3

Create Agent with Tool

Create app.py
4

Start Agents

Execute your script:
Terminal

MCP Tools (Model Context Protocol)

MCP allows agents to use external tools via standardized protocols. This is the recommended way to add powerful tools to your agents.

MCP Overview

Introduction to Model Context Protocol

MCP Transports

stdio, HTTP, WebSocket, and SSE transports

Built-in Search Tools

PraisonAI includes built-in search tools that work with multiple providers:

Tavily

AI-optimized search with web search, news, and content extraction

You.com

Web search with AI-powered results

Exa

Neural search for finding similar content
Fast Context provides rapid parallel code search for AI agents - 10-20x faster than traditional methods:

Fast Context

Rapid parallel code search with caching and multi-language support

In-build Tools in PraisonAI

Search Tools

Tools for searching and retrieving information from various sources

Tavily Tools

AI-optimized web search, news, and content extraction

You.com Tools

Web search with AI-powered results

Exa Tools

Neural search for finding similar content

Python Tools

Essential Python utilities for data manipulation and scripting

Spider Tools

Web crawling and scraping capabilities for data extraction

Arxiv Tools

Access and search academic papers from arXiv repository

Newspaper Tools

Extract and parse content from news articles and websites

DuckDB Tools

Fast analytical SQL database operations and queries

DuckDuckGo Tools

Web search functionality using DuckDuckGo’s API

SearxNG Tools

Privacy-focused web search using local SearxNG instance

Calculator Tools

Perform mathematical calculations and conversions

YAML Tools

Parse and manipulate YAML format data

JSON Tools

Handle JSON data structures and operations

Pandas Tools

Data analysis and manipulation using Pandas

YFinance Tools

Fetch financial market data from Yahoo Finance

Shell Tools

Execute shell commands and system operations

AST-Grep Tools

AST-based structural code search and rewrite

Wikipedia Tools

Access and search Wikipedia articles and data

XML Tools

Process and manipulate XML format data

File Tools

File system operations and management utilities

Excel Tools

Work with Excel spreadsheets and workbooks

CSV Tools

Handle CSV file operations and transformations

Tools Overview

Search Tools

Tools for searching and retrieving information from various sources

File Tools

Tools for reading, writing, and manipulating files

API Tools

Tools for interacting with external APIs and services

Advanced Tool Features

Tool Configuration

Tool Chaining

Tool Categories

Data Collection Tools

  • Web scraping
  • API integration
  • Database queries

Processing Tools

  • Data transformation
  • Text analysis
  • Image processing

Output Tools

  • File generation
  • Report creation
  • Data visualization

Tool Integration

Adding Tools to Agents

Tool Dependencies

Tool Guidelines

Best Practices

  1. Type Hints
    • Use Python type hints
    • Define clear input/output types
    • Document complex types
  2. Documentation
    • Write clear docstrings
    • Explain parameters
    • Provide usage examples
  3. Error Handling
    • Handle exceptions gracefully
    • Return meaningful errors
    • Validate inputs

Tool Types

  1. Search Tools
    • Web search
    • Database queries
    • Document search
  2. File Tools
    • Read/write operations
    • File conversion
    • Data extraction
  3. API Tools
    • REST API calls
    • GraphQL queries
    • Service integration

Best Practices Summary

Following these best practices will help you create robust, efficient, and secure tools in PraisonAI.

Design Principles

Each tool should have one clear purpose and do it well. Avoid creating tools that try to do too many things.
Define explicit input/output types and maintain consistent parameter naming.
Always include detailed docstrings and type hints.

Performance Optimization

Optimize resource usage and processing time.
Properly handle resource allocation and cleanup.
Implement caching for frequently accessed data.
Use async/await for I/O-bound operations.

Security Best Practices

Always validate and sanitize inputs to prevent security vulnerabilities.
Implement rate limiting for API calls to prevent abuse.
Securely handle API keys and credentials using environment variables.
Hide sensitive information in error messages to prevent information leakage.

Pro Tip: Start with these practices from the beginning of your project. It’s easier to maintain good practices than to retrofit them later.

Forcing Tool Usage with tool_choice

By default, LLMs may skip calling tools even when instructed. Use tool_choice to control this behavior.
tool_choice
string
default:"auto"
Controls when the LLM calls tools:
  • auto - LLM decides whether to call tools (default)
  • required - LLM must call a tool before responding
  • none - LLM cannot call tools (text response only)
Use tool_choice: required in YAML workflows when you need guaranteed tool execution. This is especially important for research agents that must search the web.

Tool Profiles

Tool profiles are composable, named sets of tools that eliminate duplication across agent configurations. The SDK ships with built-in profiles that auto-sync to all consumers.

Built-in Profiles

Using Profiles