Class Gemini.Builder

java.lang.Object
com.google.adk.models.Gemini.Builder
Enclosing class:
Gemini

public static class Gemini.Builder extends Object
Builder for Gemini.
  • Method Details

    • modelName

      @CanIgnoreReturnValue public Gemini.Builder modelName(String 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

      @CanIgnoreReturnValue public Gemini.Builder apiClient(com.google.genai.Client apiClient)
      Sets the explicit Client instance for making API calls. If this is set, apiKey and vertexCredentials will be ignored.
      Parameters:
      apiClient - The client instance.
      Returns:
      This builder.
    • apiKey

      @CanIgnoreReturnValue public Gemini.Builder apiKey(String apiKey)
      Sets the Google Gemini API key. If apiClient(Client) is also set, the explicit client will take precedence. If vertexCredentials(VertexCredentials) is also set, this apiKey will take precedence.
      Parameters:
      apiKey - The API key.
      Returns:
      This builder.
    • vertexCredentials

      @CanIgnoreReturnValue public Gemini.Builder vertexCredentials(VertexCredentials vertexCredentials)
      Sets the Vertex AI credentials. If apiClient(Client) or apiKey(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. Pass HttpClientFactory.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 explicit apiClient is supplied.
      Parameters:
      httpExecutorService - The executor for HTTP dispatcher threads.
      Returns:
      This builder.
    • build

      public Gemini build()
      Builds the Gemini instance.
      Returns:
      A new Gemini instance.
      Throws:
      NullPointerException - if modelName is null.