Tool

public final 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

Nested types

public static class Tool.Companion

Public methods

static final @NonNull Tool
functionDeclarations(
    @NonNull List<@NonNull FunctionDeclaration> functionDeclarations
)

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

static final @NonNull Tool

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

Public methods

functionDeclarations

public static final @NonNull Tool functionDeclarations(
    @NonNull List<@NonNull FunctionDeclaration> functionDeclarations
)

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

Parameters
@NonNull List<@NonNull FunctionDeclaration> functionDeclarations

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

googleSearch

public static final @NonNull Tool googleSearch(@NonNull GoogleSearch googleSearch)

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
@NonNull GoogleSearch googleSearch

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

Returns
@NonNull Tool

A Tool configured for Google Search.