Tool Management

New
Updated

The Tools namespace lets you manage a registry of tools that AI agents can discover and use. Tools are organized into categories and searchable via hybrid semantic + keyword search.

In this guide you'll learn how to:

  • Create and organize tools into categories
  • Search tools using natural language queries
  • Manage the full tool lifecycle
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

Set Up Categories

Organize your tools into categories before creating tools.

setup-categories.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
const defiCat = await chaos.tools.categories.create({ name: 'DeFi Protocols' });
const dataCat = await chaos.tools.categories.create({ name: 'Data & Analytics' });
 
console.log(`Created categories: ${defiCat.id}, ${dataCat.id}`);

Register Tools

Create tools with descriptive names and descriptions — these are used for semantic search matching.

register-tools.ts
const priceTool = await chaos.tools.create({
  name: 'token-price-fetcher',
  description: 'Fetches real-time and historical token prices from multiple DEXes and CEXes',
});
 
const liqTool = await chaos.tools.create({
  name: 'liquidity-analyzer',
  description: 'Analyzes liquidity depth and slippage across Uniswap, Curve, and Balancer pools',
});
 
console.log(`Registered: ${priceTool.name}, ${liqTool.name}`);

Search Tools

Use natural language queries to find relevant tools. Hybrid search combines semantic understanding with keyword matching.

search-tools.ts
const results = await chaos.tools.searchHybrid({
  queries: [
    'I need to check token prices',
    'analyze DEX liquidity',
  ],
});
 
for (const r of results) {
  console.log(`\nQuery: "${r.query}"`);
  for (const tool of r.results) {
    console.log(`  ✓ ${tool.name}${tool.description}`);
  }
}

List & Browse

Browse the full tool registry with pagination and filtering.

browse-tools.ts
// List all tools
const { data: allTools, total } = await chaos.tools.list({ page: 1, limit: 50 });
console.log(`${total} tools registered`);
 
// List all categories
const { data: cats } = await chaos.tools.categories.list();
for (const c of cats) {
  console.log(`Category: ${c.name} (${c.id})`);
}
Was this helpful?