Class Gemini.Builder
java.lang.Object
com.google.adk.models.Gemini.Builder
- Enclosing class:
Gemini
-
Method Summary
Modifier and TypeMethodDescriptionapiClient(com.google.genai.Client apiClient) Sets the explicitClientinstance for making API calls.Sets the Google Gemini API key.build()Builds theGeminiinstance.httpExecutorService(ExecutorService httpExecutorService) Sets the executor for the shared HTTP client's dispatcher.Sets the name of the Gemini model to use.vertexCredentials(VertexCredentials vertexCredentials) Sets the Vertex AI credentials.
-
Method Details
-
modelName
Sets the name of the Gemini model to use.- Parameters:
modelName- The model name (e.g., "gemini-2.0-flash").- Returns:
- This builder.
-
apiClient
Sets the explicitClientinstance for making API calls. If this is set, apiKey and vertexCredentials will be ignored.- Parameters:
apiClient- The client instance.- Returns:
- This builder.
-
apiKey
Sets the Google Gemini API key. IfapiClient(Client)is also set, the explicit client will take precedence. IfvertexCredentials(VertexCredentials)is also set, this apiKey will take precedence.- Parameters:
apiKey- The API key.- Returns:
- This builder.
-
vertexCredentials
Sets the Vertex AI credentials. IfapiClient(Client)orapiKey(String)are also set, they will take precedence over these credentials.- Parameters:
vertexCredentials- The Vertex AI credentials.- Returns:
- This builder.
-
httpExecutorService
@CanIgnoreReturnValue public Gemini.Builder httpExecutorService(ExecutorService httpExecutorService) Sets the executor for the shared HTTP client's dispatcher. PassHttpClientFactory.daemonExecutor(String)so a standalone or CLI JVM can exit once work is done, or a container-managed executor in a managed environment. Applies only when the client is built from an API key, Vertex credentials, or the default; it is ignored when an explicitapiClientis supplied.- Parameters:
httpExecutorService- The executor for HTTP dispatcher threads.- Returns:
- This builder.
-
build
Builds theGeminiinstance.- Returns:
- A new
Geminiinstance. - Throws:
NullPointerException- if modelName is null.
-