Tool

class Tool

Contains a set of tools (like function declarations) that the model has access to. These tools can be used to gather information or complete tasks.

Summary

Public companion functions

Tool

Creates a Tool instance that provides the model with access to the functionDeclarations.

Tool
googleSearch(googleSearch: GoogleSearch)

Creates a Tool instance that allows the model to use Grounding with Google Search.

Public companion functions

functionDeclarations

fun functionDeclarations(functionDeclarations: List<FunctionDeclaration>): Tool

Creates a Tool instance that provides the model with access to the functionDeclarations.

Parameters
functionDeclarations: List<FunctionDeclaration>

The list of functions that this tool allows the model access to.

googleSearch

fun googleSearch(googleSearch: GoogleSearch = GoogleSearch()): Tool

Creates a Tool instance that allows the model to use Grounding with Google Search.

Grounding with Google Search can be used to allow the model to connect to Google Search to access and incorporate up-to-date information from the web into it's responses.

When using this feature, you are required to comply with the "Grounding with Google Search" usage requirements for your chosen API provider: Gemini Developer API or Vertex AI Gemini API (see Service Terms section within the Service Specific Terms).

Parameters
googleSearch: GoogleSearch = GoogleSearch()

An empty GoogleSearch object. The presence of this object in the list of tools enables the model to use Google Search.

Returns
Tool

A Tool configured for Google Search.