Gemini

constructor(client: Client, name: String, speechConfig: SpeechConfig? = null)

Creates a Gemini from a preconfigured GenAI SDK Client, for callers that need a custom transport or auth. Each generate request and live connection appends ADK's tracking tag to the client's user-agent and x-goog-api-client headers. The SDK matches these names exactly, so a client header spelled User-Agent replaces the merged value.

Parameters

client

The Client instance from the GenAI SDK used for making API calls.

name

The name of the specific Gemini model to use (e.g., "gemini-3.1-flash-lite-preview").

speechConfig

The speech config for live sessions; see Gemini.speechConfig.


constructor(name: String, apiKey: String? = null, speechConfig: SpeechConfig? = null)

Creates a Gemini instance using a Google AI API key for authentication. Its client retries transient failures with the GenAI SDK's default retry options; pass your own Client for other retry settings.

Parameters

name

The name of the specific Gemini model to use (e.g., "gemini-3.1-flash-lite-preview").

apiKey

The Google AI API key. If not provided, falls back to GOOGLE_API_KEY or GEMINI_API_KEY environment variables on GenAI SDK level.

speechConfig

The speech config for live sessions; see Gemini.speechConfig.


constructor(name: String, vertexCredentials: VertexCredentials, speechConfig: SpeechConfig? = null)

Creates a Gemini instance using Vertex AI credentials for authentication. Its client retries transient failures with the GenAI SDK's default retry options; pass your own Client for other retry settings.

Parameters

name

The name of the specific Gemini model to use (e.g., "gemini-3.1-flash-lite-preview").

vertexCredentials

The Vertex AI credentials to use.

speechConfig

The speech config for live sessions; see Gemini.speechConfig.