LiveService class

Service for connecting to the Gemini Live API via WebSocket.

Constructors

LiveService({required String apiKey, String? apiVersion, Object? httpOptions, GenAICredentials? credentials, bool? supportsHeaders, void logger(String message)?, WebSocketConnector? connector, Duration setupTimeout = const Duration(seconds: 10), String dartVersionProvider()?})
Creates a LiveService client configured with apiKey, apiVersion, and optional httpOptions and credentials.

Properties

apiKey → String
The Gemini Developer API key or ephemeral client auth token.
final
apiVersion → String
The target API version path segment (defaults to 'v1beta').
final
credentials → GenAICredentials?
Optional bearer token and quota project credentials resolved per connection.
final
hashCode → int
The hash code for this object.
no setterinherited
httpOptions → HttpOptions?
Optional client-level HTTP and WebSocket transport options (baseUrl, apiVersion, headers).
final
logger → void Function(String message)?
Optional logger for WebSocket traffic.
final
music ↔ LiveMusicService
Service for generating realtime music streams (Lyria Live).
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportsHeaders → bool
Whether the underlying WebSocket transport forwards handshake HTTP headers.
final

Methods

connect(LiveConnectParameters params) → Future<LiveSession>
Establishes a WebSocket connection to the Live API using params.
handleWebSocketDataForTesting(dynamic data, LiveCallbacks callbacks) → void
Processes incoming WebSocket data through callbacks for unit testing.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

buildSetupMessage(LiveConnectParameters params, {List<Tool>? resolvedToolsOverride}) → LiveClientMessage
Builds and validates the initial LiveClientMessage setup payload for params.
buildSetupMessageAsync(LiveConnectParameters params) → Future<LiveClientMessage>
Resolves any asynchronous CallableTool instances in params and builds the initial LiveClientMessage setup payload.
buildWebSocketBaseUrl({required String apiKey, HttpOptions? clientHttpOptions, HttpOptions? sessionHttpOptions}) → String
Computes the WebSocket base URL from httpOptions, converting http/https schemes to wss when authentication is present, or returning the custom baseUrl as-is when apiKey is empty (proxy mode).
dartVersion() → String
Returns the current Dart runtime version string.
mergeLiveHttpOptions(HttpOptions? clientHttpOptions, HttpOptions? sessionHttpOptions) → HttpOptions
Merges clientHttpOptions with sessionHttpOptions for a Live session.
normalizeModelName(String model) → String
Normalizes and validates a model identifier matching upstream tModel.
validateFunctionResponses(List<FunctionResponse> functionResponses) → List<FunctionResponse>
Validates that every item in functionResponses has a non-empty name, response, and id.
validateRealtimeBlob(Blob blob, {required String expectedPrefix}) → void
Validates that blob has a MIME type starting with expectedPrefix.
validateTools(List<Tool>? tools) → void
Validates that tools do not use Vertex/Enterprise-only search parameters unsupported in the Gemini Developer API.