Table of Contents

Class Tool

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

Tool details of a tool that the model may use to generate a response.

public record Tool : IEquatable<Tool>
Inheritance
Tool
Implements
Inherited Members

Properties

CodeExecution

Optional. CodeExecution tool type. Enables the model to execute code as part of generation.

[JsonPropertyName("codeExecution")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ToolCodeExecution? CodeExecution { get; set; }

Property Value

ToolCodeExecution

ComputerUse

Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.

[JsonPropertyName("computerUse")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ComputerUse? ComputerUse { get; set; }

Property Value

ComputerUse

EnterpriseWebSearch

Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.

[JsonPropertyName("enterpriseWebSearch")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public EnterpriseWebSearch? EnterpriseWebSearch { get; set; }

Property Value

EnterpriseWebSearch

FileSearch

Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.

[JsonPropertyName("fileSearch")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public FileSearch? FileSearch { get; set; }

Property Value

FileSearch

FunctionDeclarations

Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.

[JsonPropertyName("functionDeclarations")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<FunctionDeclaration>? FunctionDeclarations { get; set; }

Property Value

List<FunctionDeclaration>

GoogleMaps

Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.

[JsonPropertyName("googleMaps")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GoogleMaps? GoogleMaps { get; set; }

Property Value

GoogleMaps

GoogleSearch

Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

[JsonPropertyName("googleSearch")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GoogleSearch? GoogleSearch { get; set; }

Property Value

GoogleSearch

GoogleSearchRetrieval

Optional. Specialized retrieval tool that is powered by Google Search.

[JsonPropertyName("googleSearchRetrieval")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GoogleSearchRetrieval? GoogleSearchRetrieval { get; set; }

Property Value

GoogleSearchRetrieval

McpServers

Optional. MCP Servers to connect to. This field is not supported in Vertex AI.

[JsonPropertyName("mcpServers")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<McpServer>? McpServers { get; set; }

Property Value

List<McpServer>

ParallelAiSearch

Optional. If specified, Vertex AI will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation. This field is not supported in Gemini API.

[JsonPropertyName("parallelAiSearch")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ToolParallelAiSearch? ParallelAiSearch { get; set; }

Property Value

ToolParallelAiSearch

Retrieval

Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.

[JsonPropertyName("retrieval")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Retrieval? Retrieval { get; set; }

Property Value

Retrieval

UrlContext

Optional. Tool to support URL context retrieval.

[JsonPropertyName("urlContext")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public UrlContext? UrlContext { get; set; }

Property Value

UrlContext

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a Tool object.

public static Tool? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

Tool

The deserialized Tool object, or null if deserialization fails.