API Reference
API reference for tool calling.
tool() Parameters
namerequiredstring
descriptionrequiredstring
schemarequiredz.ZodObject
executerequired(args: z.infer<T>) => ToolResult | Promise<ToolResult>
strictboolean
falsestrict value — mixing is not allowed. Alternatively, use createModel({ strict: true }) to enable strict mode globally. The SDK automatically switches to the Beta endpoint and passes strict: true to the API. The server validates the JSON Schema to ensure the model strictly follows the defined parameter structure. requiredboolean
falsetimeoutnumber
60000retriesnumber
0compactboolean | ToolCompactConfig
undefinedtrue, tool results exceeding the threshold are compressed via an LLM to save context window space. Pass an object { threshold?: number, model?: Model } for custom settings. Tool Type
ToolReturnType<typeof tool>
tool() function. Contains the original configuration properties and processed parameters (JSON Schema) and execute (wrapped execution function). StrictToolStrictTool
strict: true. All properties of this tool definition must have strict: true. NonStrictToolNonStrictTool
strict: false or undefined. The default tool type when strict mode is not enabled. ConsistentToolsStrictTool[] | NonStrictTool[]
generateText and agent methods. Ensures all tools in an array have consistent strict mode settings — either all strict or all non-strict. Tool Result Types
ToolSuccess{ success: true, data: T }
data field contains the return value of the execute function. ToolFailure{ success: false, error: string }
error field contains the error description. ToolChoice Type
autostring
nonestring
requiredstring
{ type: 'function', function: { name: string } }object
required: true. 
