Skip to main content
PraisonAI TypeScript provides a powerful plugin system that allows you to create custom tools and extend agent capabilities. This matches the Python SDK’s extensibility pattern.

Quick Start

1

Simple Usage

2

With Configuration

Overview

There are three ways to create custom tools:
  1. Class-based - Extend BaseTool for complex tools with state
  2. Function-based - Use createTool() for simple inline tools
  3. Decorator-style - Use tool() function for quick tool creation

BaseTool Class

The BaseTool abstract class is the foundation for creating custom tools:

BaseTool Methods

Safe Execution

Use safeRun() for error handling:

createTool Function

For simple tools, use the createTool() helper:

tool() Function

The tool() function provides a decorator-style approach:

Tool Registry

Register and manage tools with ToolRegistry:

Using Tools with Agents

Pass tools to agents for function calling:

Creating NPM Plugins

You can distribute tools as npm packages:
Users can then install and use:

Tool Validation

Validate tools before use:

OpenAI Schema Generation

Get OpenAI-compatible schemas for any tool:

Best Practices

  1. Clear descriptions - Write detailed descriptions for LLM understanding
  2. Type safety - Use TypeScript generics for input/output types
  3. Error handling - Use safeRun() or try/catch in run()
  4. Validation - Define parameters schema for input validation
  5. Versioning - Set version for tracking tool changes
  6. Testing - Write unit tests for your tools

Example: Complete Plugin

Tools

Built-in tools

Custom Tools

More examples