public GenerativeModel withToolConfig(ToolConfig toolConfig) {
    checkNotNull(
        toolConfig,
        "toolConfig can't be null. Use Optional.empty() if no tool config is intended.");
    return new GenerativeModel(
        modelName,
        generationConfig,
        safetySettings,
        tools,
        Optional.of(toolConfig),
        systemInstruction,
        vertexAi);
  }
Creates a copy of the current model with updated tool config.

@param toolConfig a {@link com.google.cloud.vertexai.api.ToolConfig} that will be used in the
    new model.
@return a new {@link GenerativeModel} instance with the specified tool config.
java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/GenerativeModel.java