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 optionalhttpOptionsandcredentials.
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
datathroughcallbacksfor 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
paramsand builds the initial LiveClientMessage setup payload. -
buildWebSocketBaseUrl(
{required String apiKey, HttpOptions? clientHttpOptions, HttpOptions? sessionHttpOptions}) → String -
Computes the WebSocket base URL from httpOptions, converting
http/httpsschemes towsswhen authentication is present, or returning the custombaseUrlas-is whenapiKeyis empty (proxy mode). -
dartVersion(
) → String - Returns the current Dart runtime version string.
-
mergeLiveHttpOptions(
HttpOptions? clientHttpOptions, HttpOptions? sessionHttpOptions) → HttpOptions -
Merges
clientHttpOptionswithsessionHttpOptionsfor 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
functionResponseshas a non-emptyname,response, andid. -
validateRealtimeBlob(
Blob blob, {required String expectedPrefix}) → void -
Validates that
blobhas a MIME type starting withexpectedPrefix. -
validateTools(
List< Tool> ? tools) → void -
Validates that
toolsdo not use Vertex/Enterprise-only search parameters unsupported in the Gemini Developer API.