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 |
functionDeclarations(functionDeclarations: List<FunctionDeclaration>)Creates a |
Tool |
googleSearch(googleSearch: GoogleSearch)Creates a |
Tool |
@PublicPreviewAPICreates a |
Public companion functions
codeExecution
fun codeExecution(): Tool
Creates a Tool instance that allows the model to use code execution.
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 |
urlContext
@PublicPreviewAPI
fun urlContext(urlContext: UrlContext = UrlContext()): Tool
Creates a Tool instance that allows you to provide additional context to the models in the form of public web URLs. By including URLs in your request, the Gemini model will access the content from those pages to inform and enhance its response.
| Parameters | |
|---|---|
urlContext: UrlContext = UrlContext() |
Specifies the URL context configuration. |