Skip to main content

AI SDK Tools Registry

PraisonAI provides a unified registry of AI SDK tools that can be used with agents. All tools are lazy-loaded and have optional dependencies.

Quick Start

import { Agent, tools } from 'praisonai';

const agent = new Agent({
  name: 'Assistant',
  tools: [
    tools.tavily(),      // Web search
    tools.exa(),         // Semantic search
    tools.firecrawl(),   // Web scraping
  ],
});

const result = await agent.run('Research the latest AI developments');

Available Tools

ToolPackageDescriptionRequired Env
tavily@tavily/ai-sdkWeb search, extract, crawlTAVILY_API_KEY
exa@exalabs/ai-sdkSemantic web searchEXA_API_KEY
perplexity@perplexity-ai/ai-sdkReal-time searchPERPLEXITY_API_KEY
firecrawl@mendable/firecrawl-jsWeb scraping & crawlingFIRECRAWL_API_KEY
codeExecutionai-sdk-tool-code-executionPython code sandboxVERCEL_OIDC_TOKEN
guard@superagent-ai/ai-sdkPrompt injection detectionSUPERAGENT_API_KEY
redact@superagent-ai/ai-sdkPII redactionSUPERAGENT_API_KEY
verify@superagent-ai/ai-sdkClaim verificationSUPERAGENT_API_KEY
valyuWebSearch@valyu/ai-sdkDomain-specific searchVALYU_API_KEY
airweave@airweave/sdkRAG/semantic searchAIRWEAVE_API_KEY
bedrockCodeInterpreterbedrock-agentcoreAWS code executionAWS credentials

Installation

Install only the tools you need:
# Web search tools
npm install @tavily/ai-sdk
npm install @exalabs/ai-sdk

# Security tools
npm install @superagent-ai/ai-sdk

# Code execution
npm install ai-sdk-tool-code-execution

Using the Tools Facade

The tools object provides a simple API for all built-in tools:
import { tools } from 'praisonai';

// Search tools
tools.tavily({ maxResults: 5 })
tools.exa({ highlights: true })
tools.perplexity()

// Content tools
tools.tavilyExtract()
tools.tavilyCrawl()
tools.firecrawl()
tools.firecrawlCrawl()

// Security tools
tools.guard()
tools.redact()
tools.verify()

// Code execution
tools.codeExecution()
tools.codeMode()

// Domain search (Valyu)
tools.valyuWebSearch()
tools.valyuFinanceSearch()
tools.valyuPaperSearch()
tools.valyuSecSearch()

// Custom tools
tools.custom({ name, description, parameters, execute })

Registry API

Access the underlying registry for advanced use cases:
import { getToolsRegistry, registerBuiltinTools } from 'praisonai';

// Register all built-in tools
registerBuiltinTools();

// Get the registry
const registry = getToolsRegistry();

// List all tools
const allTools = registry.list();

// Get tool metadata
const metadata = registry.getMetadata('tavily');

// Create a tool instance
const tool = registry.create('tavily', { maxResults: 10 });

// Check if a tool is registered
const exists = registry.has('tavily');

Middleware

Add middleware to all tool executions:
import { 
  getToolsRegistry,
  createLoggingMiddleware,
  createTimeoutMiddleware,
  createRedactionMiddleware 
} from 'praisonai';

const registry = getToolsRegistry();

// Add logging
registry.use(createLoggingMiddleware());

// Add 30-second timeout
registry.use(createTimeoutMiddleware(30000));

// Add PII redaction
registry.use(createRedactionMiddleware());

Available Middleware

MiddlewareDescription
createLoggingMiddleware()Log tool calls and results
createTimeoutMiddleware(ms)Timeout long operations
createRedactionMiddleware()Redact PII from results
createRateLimitMiddleware(limit, window)Rate limit tool calls
createRetryMiddleware(attempts, delay)Retry failed calls
createTracingMiddleware()Add tracing context
createValidationMiddleware()Validate inputs

Hooks

Set hooks for monitoring:
registry.setHooks({
  beforeToolCall: (name, input, ctx) => {
    console.log(`Starting: ${name}`);
  },
  afterToolCall: (name, input, output, ctx) => {
    console.log(`Completed: ${name}`);
  },
  onError: (name, error, ctx) => {
    console.error(`Error in ${name}:`, error);
  },
});

Custom Tools

Register your own tools:
import { tools } from 'praisonai';

const calculator = tools.custom({
  id: 'calculator',
  name: 'calculator',
  description: 'Perform arithmetic calculations',
  parameters: {
    type: 'object',
    properties: {
      expression: {
        type: 'string',
        description: 'Math expression to evaluate',
      },
    },
    required: ['expression'],
  },
  execute: async (input) => {
    const result = eval(input.expression); // Use a proper math parser
    return { result };
  },
});

const agent = new Agent({
  tools: [calculator],
});

CLI Commands

# List all tools
praisonai-ts tools list

# Get tool info
praisonai-ts tools info tavily

# Check dependencies
praisonai-ts tools doctor

# Show example
praisonai-ts tools example tavily

# Test a tool
praisonai-ts tools test tavily --live

# Register npm tool
praisonai-ts tools add @my-org/my-tool

Tool Categories

Search Tools

  • tavily - General web search with AI answers
  • exa - Semantic/neural search
  • perplexity - Real-time search with citations
  • parallel - Multi-source parallel search

Content Tools

  • tavilyExtract - Extract content from URLs
  • tavilyCrawl - Crawl websites
  • firecrawl - Advanced web scraping
  • airweave - RAG/semantic search

Security Tools

  • guard - Detect prompt injection
  • redact - Remove PII
  • verify - Verify claims

Code Execution

  • codeExecution - Vercel sandbox (Python)
  • codeMode - Custom sandboxed execution
  • bedrockCodeInterpreter - AWS sandbox

Domain Search (Valyu)

  • valyuWebSearch - General web
  • valyuFinanceSearch - Financial data
  • valyuPaperSearch - Academic papers
  • valyuBioSearch - Biology/medical
  • valyuPatentSearch - Patents
  • valyuSecSearch - SEC filings
  • valyuEconomicsSearch - Economic data
  • valyuCompanyResearch - Company info

Error Handling

Tools throw specific errors for common issues:
import { MissingDependencyError, MissingEnvVarError } from 'praisonai';

try {
  const tool = tools.tavily();
  await tool.execute({ query: 'test' });
} catch (error) {
  if (error instanceof MissingDependencyError) {
    console.log('Install:', error.installHints.npm);
  } else if (error instanceof MissingEnvVarError) {
    console.log('Set env var:', error.envVar);
  }
}