LiveAPIClient
Methods
addEventListener
addEventListener(event: | , callback: Function
): void
Adds a handler for the specified Gemini.Experimental.LiveAPIEvents or Gemini.Experimental.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.
Parameters
event:
Event class (i.e., [Gemini.Experimental.LiveAPIEvents.BidiGenerateContentSetupComplete])
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
bidiGenerateContentClientContent
bidiGenerateContentClientContent(parameters: Object
): void
Incremental update of the current conversation delivered from the client. https://ai.google.dev/gemini-api/docs/live#bidigeneratecontentclientcontent
Parameters
parameters:
Object
Returns
type:
void
bidiGenerateContentRealtimeInput
bidiGenerateContentRealtimeInput(parameters: Object
): void
User input that is sent in real time. https://ai.google.dev/gemini-api/docs/live#bidigeneratecontentrealtimeinput
Parameters
parameters:
Object
Returns
type:
void
bidiGenerateContentToolResponse
bidiGenerateContentToolResponse(parameters: Object
): void
Client generated response to a ToolCall received from the server. https://ai.google.dev/gemini-api/docs/live#bidigeneratecontenttoolresponse
Parameters
parameters:
Object
Returns
type:
void
close
close(): void
Closes the LiveAPI connection (over WebSocket) or connection attempt.
Returns
type:
void
id
id(): string
Returns the LiveAPIClient id.
Returns
type:
string
removeEventListener
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified Gemini.Experimental.LiveAPIEvents or Gemini.Experimental.Events event.
Parameters
event:
Event class (i.e., [Gemini.Experimental.LiveAPIEvents.BidiGenerateContentSetupComplete])
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
sendMediaTo
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the LiveAPI (via WebSocket) to the media unit. LiveAPI works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the LiveAPI (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
webSocketId
webSocketId(): string
Returns the LiveAPI WebSocket id.
Returns
type:
string