DefineTool()
Defines and registers a tool.Type Parameters
any
required
Input type (must have JSON tags for schema generation)
any
required
Output type (must have JSON tags for schema generation)
Parameters
*Genkit
required
Genkit instance
string
required
Unique tool name
string
required
Description of what the tool does (helps model understand when to use it)
ToolFunc[In, Out]
required
Tool implementation functionSignature:
...ToolOption
Optional tool configurationAvailable options:
ai.WithInputSchema(map[string]any)- Custom input JSON schemaai.WithInputSchemaName(string)- Reference registered schema
Returns
*ToolDef[In, Out]
Tool definition that can be passed to
WithTools()DefineMultipartTool()
Defines a tool that returns content parts (text + media).Type Parameters
any
required
Input type
Parameters
Same asDefineTool() except function returns *MultipartToolResponse.
Returns
*ToolDef[In, *MultipartToolResponse]
Multipart tool definition
DefineToolWithInputSchema()
Defines a tool with custom input schema.Tool Context
ToolContext
ToolContext provides access to runtime information during tool execution.