Class Tool


public abstract class Tool extends JsonSerializable
Tool details of a tool that the model may use to generate a response.
  • Constructor Details

    • Tool

      public Tool()
  • Method Details

    • functionDeclarations

      public abstract Optional<List<FunctionDeclaration>> functionDeclarations()
      List of function declarations that the tool supports.
    • retrieval

      public abstract Optional<Retrieval> 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.
    • googleSearchRetrieval

      public abstract Optional<GoogleSearchRetrieval> googleSearchRetrieval()
      Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search.
    • googleMaps

      public abstract Optional<GoogleMaps> googleMaps()
      Optional. Google Maps tool type. Specialized retrieval tool that is powered by Google Maps.
    • functions

      public abstract Optional<List<Method>> functions()
      The java.lang.reflect.Method instance. If provided, it will to be parsed into a list of FunctionDeclaration instances, and be assigned to the functionDeclarations field.
    • computerUse

      public abstract Optional<ComputerUse> computerUse()
      Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.
    • codeExecution

      public abstract Optional<ToolCodeExecution> codeExecution()
      Optional. CodeExecution tool type. Enables the model to execute code as part of generation.
    • enterpriseWebSearch

      public abstract Optional<EnterpriseWebSearch> 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.
    • googleSearch

      public abstract Optional<GoogleSearch> googleSearch()
      Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
    • urlContext

      public abstract Optional<UrlContext> urlContext()
      Optional. Tool to support URL context retrieval.
    • builder

      public static Tool.Builder builder()
      Instantiates a builder for Tool.
    • toBuilder

      public abstract Tool.Builder toBuilder()
      Creates a builder with the same values as this instance.
    • fromJson

      public static Tool fromJson(String jsonString)
      Deserializes a JSON string to a Tool object.