public GenerativeModel withTools(List<Tool> tools) {
    checkNotNull(tools, "tools can't be null. Use an empty list if no tool is to be used.");
    return new GenerativeModel(
        modelName,
        generationConfig,
        safetySettings,
        ImmutableList.copyOf(tools),
        toolConfig,
        systemInstruction,
        vertexAi);
  }
Creates a copy of the current model with updated tools.

@param tools a list of {@link com.google.cloud.vertexai.api.Tool} that will be used in the new
    model.
@return a new {@link GenerativeModel} instance with the specified tools.
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/GenerativeModel.java