Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Vertex AI Extension via Java

Hey all!

I'm building an Agent, and I'm trying to make it use a custom tool (Extension) that I created, it seems the Java SDK is lacking the ability to register the Tool for use such that it would execute automatically?

The extension is registered (via the experimental UI), the Java SDK I can do:

 

Tool myTool = Tool.newBuilder()
.addFunctionDeclarations(FunctionDeclaration.newBuilder()
.setName("myTool")
.setDescription("My amazing tool")
.build())
.build();

and later do:

// Create the request to Gemini
GenerateContentRequest request = GenerateContentRequest.newBuilder()
.setModel("gemini-2.0-flash-exp")
.setSystemInstruction(systemInstruction)
.addContents(userMessage)
.setGenerationConfig(generationConfig)
.addTools(myTool) // Register tool with automatic execution ??
.build();

But can't find anywhere to register the Tool's endpoint.
What am I missing here?

2 1 838
1 REPLY 1