Tool CRUD & Search

Updated

Manage the full lifecycle of tools in your registry — create tools with descriptive names, list and filter them, update properties, delete them, and discover tools using hybrid semantic search.

list(params?)

Retrieve a paginated list of tools. Optionally filter by category or search keyword.

Signature:

list(params?: ToolListParams): Promise<ToolListResponse>
list-tools.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
// List all tools
const { data: tools, total } = await chaos.tools.list();
console.log(`${total} tools registered`);
 
for (const t of tools) {
  console.log(`${t.name}: ${t.description ?? '(no description)'}`);
}
 
// Paginate
const page2 = await chaos.tools.list({ page: 2, limit: 10 });
 
// Filter by category
const defiTools = await chaos.tools.list({ categoryId: 'cat-defi-123' });
 
// Keyword search
const priceTools = await chaos.tools.list({ search: 'price' });

ToolListParams

FieldTypeRequiredDescription
pagenumberNoPage number
limitnumberNoResults per page
categoryIdstringNoFilter by category ID
searchstringNoKeyword search filter

create(params)

Register a new tool. At minimum, provide a name. Additional properties are accepted and passed through to the API.

Signature:

create(params: CreateToolParams): Promise<Tool>
create-tool.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
const tool = await chaos.tools.create({
  name: 'liquidity-analyzer',
  description: 'Analyzes liquidity depth and slippage across Uniswap, Curve, and Balancer pools',
});
 
console.log(`Created: ${tool.id}`);
console.log(`Name: ${tool.name}`);
console.log(`Description: ${tool.description}`);
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop

update(toolId, params)

Update a tool's properties. Returns a confirmation message.

Signature:

update(toolId: string, params: UpdateToolParams): Promise<{ message: string }>
update-tool.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
const result = await chaos.tools.update('tool-id', {
  description: 'Updated: analyzes liquidity across all major DEXes including Uniswap V4',
});
 
console.log(result.message);

delete(toolId)

Remove a tool from the registry.

Signature:

delete(toolId: string): Promise<void>
delete-tool.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
await chaos.tools.delete('tool-id');
console.log('Tool deleted');

searchHybrid(params)

Run a batch semantic + keyword hybrid search across all tools. Pass multiple queries at once — each returns its own ranked list of matching tools.

Signature:

searchHybrid(params: BatchHybridSearchParams): Promise<QueryToolSearchResult[]>
search-hybrid.ts
import { Chaos } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
const results = await chaos.tools.searchHybrid({
  queries: [
    'fetch real-time token prices',
    'analyze DEX liquidity depth',
    'monitor wallet balances on Ethereum',
  ],
});
 
for (const r of results) {
  console.log(`\nQuery: "${r.query}"`);
  for (const tool of r.results) {
    console.log(`  ${tool.name}: ${tool.description ?? ''}`);
  }
}
[@portabletext/react] Unknown block type "callout", specify a component for it in the `components.types` prop
Was this helpful?