Tool
Tool<
INPUT,OUTPUT> =object&ToolOutputProperties<INPUT,OUTPUT> &object& {type?:"function"; } | {type:"dynamic"; } | {args:Record<string,unknown>;id:`${string}.${string}`;name:string;type:"provider-defined"; }
Defined in: node_modules/.bun/@ai-sdk+provider-utils@3.0.25+27912429049419a2/node_modules/@ai-sdk/provider-utils/dist/index.d.ts:728
A tool contains the description and the schema of the input that the tool expects. This enables the language model to generate the input.
The tool can also contain an optional execute function for the actual execution function of the tool.
Type Declaration
Section titled “Type Declaration”description?
Section titled “description?”
optionaldescription?:string
An optional description of what the tool does. Will be used by the language model to decide whether to use the tool. Not used for provider-defined tools.
inputSchema
Section titled “inputSchema”inputSchema:
FlexibleSchema<INPUT>
The schema of the input that the tool expects. The language model will use this to generate the input. It is also used to validate the output of the language model. Use descriptions to make the input understandable for the language model.
onInputAvailable?
Section titled “onInputAvailable?”
optionalonInputAvailable?: (options) =>void|PromiseLike<void>
Optional function that is called when a tool call can be started, even if the execute function is not provided.
Parameters
Section titled “Parameters”options
Section titled “options”object & ToolCallOptions
Returns
Section titled “Returns”void | PromiseLike<void>
onInputDelta?
Section titled “onInputDelta?”
optionalonInputDelta?: (options) =>void|PromiseLike<void>
Optional function that is called when an argument streaming delta is available. Only called when the tool is used in a streaming context.
Parameters
Section titled “Parameters”options
Section titled “options”object & ToolCallOptions
Returns
Section titled “Returns”void | PromiseLike<void>
onInputStart?
Section titled “onInputStart?”
optionalonInputStart?: (options) =>void|PromiseLike<void>
Optional function that is called when the argument streaming starts. Only called when the tool is used in a streaming context.
Parameters
Section titled “Parameters”options
Section titled “options”ToolCallOptions
Returns
Section titled “Returns”void | PromiseLike<void>
providerOptions?
Section titled “providerOptions?”
optionalproviderOptions?:ProviderOptions
Additional provider-specific metadata. They are passed through to the provider from the AI SDK and enable provider-specific functionality that can be fully encapsulated in the provider.
Type Declaration
Section titled “Type Declaration”toModelOutput?
Section titled “toModelOutput?”
optionaltoModelOutput?: (output) =>LanguageModelV2ToolResultPart["output"]
Optional conversion function that maps the tool result to an output that can be used by the language model.
If not provided, the tool result will be sent as a JSON object.
Parameters
Section titled “Parameters”output
Section titled “output”0 extends 1 & OUTPUT ? any : [OUTPUT] extends [never] ? any : NoInfer<OUTPUT>
Returns
Section titled “Returns”LanguageModelV2ToolResultPart["output"]
Type Parameters
Section titled “Type Parameters”INPUT extends JSONValue | unknown | never = any
OUTPUT
Section titled “OUTPUT”OUTPUT extends JSONValue | unknown | never = any