Gemini
Implementation of Model that interacts with Google Gemini models using the GenAI SDK.
This class provides functionality to generate content from Gemini models, supporting both unary and streaming responses. It can be configured to use either a Google AI API key or Vertex AI credentials for authentication.
GenAI SDK based Gemini currently prevents usage of API_KEY and GoogleCredentials on Android. Use Firebase AI instead.
Constructors
Creates a Gemini instance 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; a client header spelled User-Agent replaces the merged value. On the Gemini API, requests also specify v1beta unless the client sets an API version.
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. Gemini API requests from this instance use v1beta unless GOOGLE_GENAI_API_VERSION sets a version.
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.
Types
Properties
Reports LlmCapabilities.outputSchemaAndTools on Vertex AI for every model except gemini-2.* and the Gemini models seen to skip tool calls when a request also sets a response schema, such as gemini-3.8-flash. On the Gemini API it never does, as in Python ADK.
The speech config for live sessions opened by this model. When set, it replaces the request's own speech config at connect, as in ADK Python.
Functions
Opens a live session configured by LlmRequest.liveConnectConfig (using request.model when set), returning once the server confirms setup and throwing if the server refuses it. If the caller is cancelled while the session opens, the session is closed in the background. Reconnection is not handled here, though a Vertex AI resume with transparent unset asks for transparent resumption.
Generates content for the given LlmRequest. This returns a Flow of LlmResponses.