For the complete documentation index, see llms.txt. This page is also available as Markdown.

Custom Tools

Create custom tools that AI models can invoke.

Tools (also called functions) are actions that AI models can request to be executed. They enable AI to interact with your application, query data, or perform operations.

What Are Tools?

When you enable tools in a chat request, the AI model can:

  1. Recognize when it needs to perform an action

  2. Request tool execution with arguments

  3. Use the result to continue the conversation

User: "What's the current inventory for product SKU-123?"

AI thinks: "I should use the inventory lookup tool"

AI requests: InventoryTool.Execute({ sku: "SKU-123" })

Tool returns: { quantity: 47, location: "Warehouse A" }

AI responds: "Product SKU-123 has 47 units in stock at Warehouse A."

Tool Architecture

A tool consists of:

  1. Metadata - ID, name, description, scope via [AITool] attribute

  2. Arguments - Optional input parameters as a typed class

  3. Implementation - The ExecuteAsync method

Quick Start

Tool Without Arguments

Tool With Arguments

Registration

Tools are auto-discovered via the [AITool] attribute and IDiscoverable interface. To manually control registration:

Key Concepts

Arguments Use Description Attributes

The [Description] attribute tells the AI what each argument is for:

Tools Support Dependency Injection

Inject services through the constructor:

Mark Destructive Tools

Tools that modify data should be marked as destructive:

Destructive tools ask the editor for approval by default. For a destructive tool whose changes editors can undo themselves, such as saving a draft, set RequiresApproval = false. See Destructive Tools and Approval.

In This Section

Creating a Tool

Last updated

Was this helpful?