Class GenerativeModel.Builder (1.2.0)

publicstaticclass GenerativeModel.Builder

Builder class for GenerativeModel.

Inheritance

java.lang.Object > GenerativeModel.Builder

Constructors

Builder()

publicBuilder()

Methods

build()

publicGenerativeModelbuild()
Returns
Type Description
GenerativeModel

setGenerationConfig(GenerationConfig generationConfig)

publicGenerativeModel.BuildersetGenerationConfig(GenerationConfiggenerationConfig)

Sets com.google.cloud.vertexai.api.GenerationConfig that will be used by default to interact with the generative model.

Parameter
Name Description
generationConfig GenerationConfig
Returns
Type Description
GenerativeModel.Builder

setModelName(String modelName)

publicGenerativeModel.BuildersetModelName(StringmodelName)

Sets the name of the generative model. This is required for building a GenerativeModel instance. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro", where "gemini-pro" is the model name. Valid model names can be found at https://cloud.google.com/vertex-ai/docs/generative-ai/learn/models#gemini-models

Parameter
Name Description
modelName String
Returns
Type Description
GenerativeModel.Builder

setSafetySettings(List<SafetySetting> safetySettings)

publicGenerativeModel.BuildersetSafetySettings(List<SafetySetting>safetySettings)

Sets a list of com.google.cloud.vertexai.api.SafetySetting that will be used by default to interact with the generative model.

Parameter
Name Description
safetySettings List<SafetySetting>
Returns
Type Description
GenerativeModel.Builder

setTools(List<Tool> tools)

publicGenerativeModel.BuildersetTools(List<Tool>tools)

Sets a list of com.google.cloud.vertexai.api.Tool that will be used by default to interact with the generative model.

Parameter
Name Description
tools List<Tool>
Returns
Type Description
GenerativeModel.Builder

setVertexAi(VertexAI vertexAi)

publicGenerativeModel.BuildersetVertexAi(VertexAIvertexAi)

Sets com.google.cloud.vertexai.VertexAI that contains the default configs for the generative model. This is required for building a GenerativeModel instance.

Parameter
Name Description
vertexAi VertexAI
Returns
Type Description
GenerativeModel.Builder

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.