Class GoogleGenAIRealtimeClient
- Namespace
- Microsoft.Extensions.AI
- Assembly
- Google.GenAI.dll
Provides an Microsoft.Extensions.AI.IRealtimeClient implementation for Google GenAI's Live API.
public sealed class GoogleGenAIRealtimeClient : IRealtimeClient, IDisposable
- Inheritance
-
GoogleGenAIRealtimeClient
- Implements
-
IRealtimeClient
- Inherited Members
Constructors
GoogleGenAIRealtimeClient(Client, string?)
Initializes a new instance wrapping an existing Client.
public GoogleGenAIRealtimeClient(Client client, string? defaultModelId = null)
Parameters
clientClientThe Google GenAI client.
defaultModelIdstringThe default model to use for realtime sessions (e.g. "gemini-2.5-flash-native-audio-preview-12-2025").
Exceptions
- ArgumentNullException
clientis null.
GoogleGenAIRealtimeClient(string, string?)
Initializes a new instance using an API key.
public GoogleGenAIRealtimeClient(string apiKey, string? defaultModelId = null)
Parameters
apiKeystringThe Google GenAI API key.
defaultModelIdstringThe default model to use for realtime sessions.
Exceptions
- ArgumentNullException
apiKeyis null or empty.
GoogleGenAIRealtimeClient(string, string, string?)
Initializes a new instance using a Google Cloud project and location.
public GoogleGenAIRealtimeClient(string project, string location, string? defaultModelId = null)
Parameters
projectstringThe Google Cloud project ID.
locationstringThe Google Cloud location (e.g. "us-central1").
defaultModelIdstringThe default model to use for realtime sessions.
Exceptions
- ArgumentNullException
projectorlocationis null or empty.
Methods
CreateSessionAsync(RealtimeSessionOptions?, CancellationToken)
Creates a new real-time session with the specified options.
public Task<IRealtimeClientSession> CreateSessionAsync(RealtimeSessionOptions? options = null, CancellationToken cancellationToken = default)
Parameters
optionsRealtimeSessionOptionsThe session options.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<IRealtimeClientSession>
The created real-time session.
Dispose()
public void Dispose()
GetService(Type, object?)
Asks the Microsoft.Extensions.AI.IRealtimeClient for an object of the specified type serviceType.
public object? GetService(Type serviceType, object? serviceKey = null)
Parameters
serviceTypeTypeThe type of object being requested.
serviceKeyobjectAn optional key that can be used to help identify the target service.
Returns
Remarks
The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the Microsoft.Extensions.AI.IRealtimeClient, including itself or any services it might be wrapping.
Exceptions
- ArgumentNullException
serviceTypeis null.