Starting April 29, 2025, Gemini 1.5 Pro and Gemini 1.5 Flash models are not available in projects that have no prior usage of these models, including new projects. For details, see Model versions and lifecycle.
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 in the Gemini models documentation:
https://cloud.google.com/vertex-ai/docs/generative-ai/learn/models#gemini-models
Sets com.google.cloud.vertexai.VertexAI that contains the default configs for the
generative model. This is required for building a GenerativeModel instance.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-16 UTC."],[],[],null,["# Class GenerativeModel.Builder (1.32.0)\n\n public static class GenerativeModel.Builder\n\nBuilder class for [GenerativeModel](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.generativeai.GenerativeModel). \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e GenerativeModel.Builder \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### Builder()\n\n public Builder()\n\nMethods\n-------\n\n### build()\n\n public GenerativeModel build()\n\n### setGenerationConfig(GenerationConfig generationConfig)\n\n public GenerativeModel.Builder setGenerationConfig(GenerationConfig generationConfig)\n\nSets [com.google.cloud.vertexai.api.GenerationConfig](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.GenerationConfig) that will be used by default to\ninteract with the generative model.\n\n### setModelName(String modelName)\n\n public GenerativeModel.Builder setModelName(String modelName)\n\nSets the name of the generative model. This is required for building a GenerativeModel\ninstance. Supported format: \"gemini-pro\", \"models/gemini-pro\",\n\"publishers/google/models/gemini-pro\", where \"gemini-pro\" is the model name. Valid model\nnames can be found in the Gemini models documentation:\n\u003chttps://cloud.google.com/vertex-ai/docs/generative-ai/learn/models#gemini-models\u003e\n\n### setSafetySettings(List\\\u003cSafetySetting\\\u003e safetySettings)\n\n public GenerativeModel.Builder setSafetySettings(List\u003cSafetySetting\u003e safetySettings)\n\nSets a list of [com.google.cloud.vertexai.api.SafetySetting](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.SafetySetting) that will be used by\ndefault to interact with the generative model.\n\n### setSystemInstruction(Content systemInstruction)\n\n public GenerativeModel.Builder setSystemInstruction(Content systemInstruction)\n\nSets a system instruction that will be used by default to interact with the generative model.\n\n### setToolConfig(ToolConfig toolConfig)\n\n public GenerativeModel.Builder setToolConfig(ToolConfig toolConfig)\n\nSets a [com.google.cloud.vertexai.api.ToolConfig](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.ToolConfig) that will be used by default to\ninteract with the generative model.\n\n### setTools(List\\\u003cTool\\\u003e tools)\n\n public GenerativeModel.Builder setTools(List\u003cTool\u003e tools)\n\nSets a list of [com.google.cloud.vertexai.api.Tool](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.api.Tool) that will be used by default to\ninteract with the generative model.\n\n### setVertexAi(VertexAI vertexAi)\n\n public GenerativeModel.Builder setVertexAi(VertexAI vertexAi)\n\nSets [com.google.cloud.vertexai.VertexAI](/vertex-ai/generative-ai/docs/reference/java/latest/com.google.cloud.vertexai.VertexAI) that contains the default configs for the\ngenerative model. This is required for building a GenerativeModel instance."]]