Firebase.
Manages asynchronous communication with Gemini model over a WebSocket connection.
Summary
Inheritance
Inherits from: IDisposable| Protected functions | |
|---|---|
| Dispose(bool disposing) | virtual void | 
| Public functions | |
|---|---|
| CloseAsync(CancellationToken cancellationToken) | TaskClose the  LiveSession. | 
| Dispose() | void | 
| ReceiveAsync(CancellationToken cancellationToken) | async IAsyncEnumerable< LiveSessionResponse >Receives a stream of responses from the server.  | 
| SendAsync(ModelContent? content, bool turnComplete, CancellationToken cancellationToken) | async TaskSends a single piece of content to the server.  | 
| SendAudioAsync(float[] audioData, CancellationToken cancellationToken) | TaskConvenience function for sending audio data in a float[] to the server.  | 
| SendAudioRealtimeAsync(ModelContent.InlineDataPart audio, CancellationToken cancellationToken) | async TaskSends audio data to the server in realtime.  | 
| SendMediaChunksAsync(List< ModelContent.InlineDataPart > mediaChunks, CancellationToken cancellationToken) | async TaskSend realtime input to the server.  | 
| SendTextRealtimeAsync(string text, CancellationToken cancellationToken) | async TaskSends text data to the server in realtime.  | 
| SendVideoRealtimeAsync(ModelContent.InlineDataPart video, CancellationToken cancellationToken) | async TaskSends video data to the server in realtime.  | 
Protected functions
Dispose
virtual void Dispose( bool disposing )
Public functions
CloseAsync
Task CloseAsync( CancellationToken cancellationToken )
Close the LiveSession. 
| Details | |||
|---|---|---|---|
| Parameters | 
 | 
Dispose
void Dispose()
ReceiveAsync
async IAsyncEnumerable< LiveSessionResponse > ReceiveAsync( CancellationToken cancellationToken )
Receives a stream of responses from the server.
Having multiple of these ongoing will result in unexpected behavior. Closes upon receiving a TurnComplete from the server.
| Details | |||
|---|---|---|---|
| Parameters | 
 | ||
| Returns | A stream of  LiveContentResponses from the backend. | 
SendAsync
async Task SendAsync( ModelContent? content, bool turnComplete, CancellationToken cancellationToken )
Sends a single piece of content to the server.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters | 
 | 
SendAudioAsync
Task SendAudioAsync( float[] audioData, CancellationToken cancellationToken )
Convenience function for sending audio data in a float[] to the server.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
 | 
SendAudioRealtimeAsync
async Task SendAudioRealtimeAsync( ModelContent.InlineDataPart audio, CancellationToken cancellationToken )
Sends audio data to the server in realtime.
Check https://ai.google.dev/api/live#bidigeneratecontentrealtimeinput for details about the realtime input usage.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
 | 
SendMediaChunksAsync
async Task SendMediaChunksAsync( List< ModelContent.InlineDataPart > mediaChunks, CancellationToken cancellationToken )
Send realtime input to the server.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
 | 
Use SendAudioRealtimeAsync, SendVideoRealtimeAsync, or SendTextRealtimeAsync instead.
Deprecated. Use SendAudioRealtimeAsync, SendVideoRealtimeAsync, or SendTextRealtimeAsync instead.
SendTextRealtimeAsync
async Task SendTextRealtimeAsync( string text, CancellationToken cancellationToken )
Sends text data to the server in realtime.
Check https://ai.google.dev/api/live#bidigeneratecontentrealtimeinput for details about the realtime input usage.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
 | 
SendVideoRealtimeAsync
async Task SendVideoRealtimeAsync( ModelContent.InlineDataPart video, CancellationToken cancellationToken )
Sends video data to the server in realtime.
Check https://ai.google.dev/api/live#bidigeneratecontentrealtimeinput for details about the realtime input usage.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
 |