Universal.Operative.Sdk.Realtime.Google.Gemini
2.1.1
See the version list below for details.
dotnet add package Universal.Operative.Sdk.Realtime.Google.Gemini --version 2.1.1
NuGet\Install-Package Universal.Operative.Sdk.Realtime.Google.Gemini -Version 2.1.1
<PackageReference Include="Universal.Operative.Sdk.Realtime.Google.Gemini" Version="2.1.1" />
<PackageVersion Include="Universal.Operative.Sdk.Realtime.Google.Gemini" Version="2.1.1" />
<PackageReference Include="Universal.Operative.Sdk.Realtime.Google.Gemini" />
paket add Universal.Operative.Sdk.Realtime.Google.Gemini --version 2.1.1
#r "nuget: Universal.Operative.Sdk.Realtime.Google.Gemini, 2.1.1"
#:package Universal.Operative.Sdk.Realtime.Google.Gemini@2.1.1
#addin nuget:?package=Universal.Operative.Sdk.Realtime.Google.Gemini&version=2.1.1
#tool nuget:?package=Universal.Operative.Sdk.Realtime.Google.Gemini&version=2.1.1
About
Universal.Operative.Sdk.Realtime.Google.Gemini adapts the Gemini Live API to Universal.Operative.Sdk.Realtime's provider-neutral IModel/IRealtimeSession/SessionEvent model, via Google's own Google.GenAI package (which ships a typed BidiGenerateContent client directly — the existing turn-based Universal.Google.Gemini.Client has no Live API bindings).
This is the second realtime adapter, deliberately chosen next (before Nova Sonic) to stress-test two things the OpenAI adapter didn't exercise: native session resumption, and parallel/async tool-call correlation.
How to Use
Installation
dotnet add package Universal.Operative.Sdk
dotnet add package Universal.Operative.Sdk.Realtime
dotnet add package Universal.Operative.Sdk.Realtime.Google.Gemini
Quick start
using Universal.Operative.Sdk.Realtime;
using Universal.Operative.Sdk.Realtime.Google.Gemini;
var model = new Model(apiKey, modelId: "gemini-2.5-flash-native-audio-preview-09-2025");
IRealtimeSession session = await model.ConnectAsync(new RealtimeSessionOptions
{
SystemPrompt = [new TextBlock("You are a helpful voice assistant.")],
Tools = [myTool],
});
IOperative operative = OperativeBuilder.Create(session).AddTool(myTool).Build();
await foreach (SessionOutputEvent e in operative.RunAsync())
{
switch (e)
{
case SessionReadyEvent: Console.WriteLine("connected"); break;
case TranscriptDeltaEvent t: Console.WriteLine($"{t.Role}: {t.Text}"); break;
case AudioOutputDeltaEvent a: /* play a.Audio (24kHz PCM16) */ break;
case SessionExpiringEvent expiring: /* about to disconnect -- see resumption below */ break;
}
}
Session resumption
Session implements IResumableSession (Capabilities.HasFlag(SessionCapabilities.NativeResumption) is true). Gemini pushes a fresh resumption handle over the life of the connection; suspend and resume with it directly:
if (session is IResumableSession resumable)
{
SessionHandle handle = await resumable.SuspendAsync();
// ... later, possibly after a restart ...
IRealtimeSession resumed = await resumable.ResumeAsync(handle);
}
Fidelity notes
- Capabilities:
AudioInProcess | ToolCalling | Transcripts | NativeResumption. - Tool results: the full
ToolResultcontent is JSON-serialized into Gemini's function-response object ({"result": ...}/{"error": ...}), not flattened to a bare string the way OpenAI's wire format requires. - Async tool scheduling:
SubmitToolResultEvent.SchedulingHintmaps to Gemini'sFunctionResponse.Scheduling(interrupt/whenIdle/silent) — a client-set hint on the response, not something the model attaches to the original call. - Barge-in: automatic (server-side VAD) only;
InterruptRequestEventthrowsNotSupportedExceptionsince Gemini has no client-sent cancel event, and manualactivityStart/activityEndisn't wired up. - Tool choice:
RealtimeSessionOptions.ToolChoicethrowsNotSupportedException--Google.GenAI.Types.LiveConnectConfighas no tool-choice-equivalent field. - Raw passthrough: video frames,
UsageMetadata, and voice-activity signals beyondinterruptedaren't promoted to canonical events -- they arrive asRawPassthroughEvent. - Auth: direct Gemini API key only; Vertex AI auth isn't wired up.
- Audio format: fixed at
Model.InputSampleRateHertz(16kHz) in andModel.OutputSampleRateHertz(24kHz) out, mono PCM16 -- not configurable, unlike the other adapters.
Google.GenAI 2.x compatibility
The adapter explicitly uses the Developer Live API's v1beta WebSocket route. Google.GenAI 2.x defaults to v1, which returns HTTP 404 during the Live handshake. Cloud/Vertex environment defaults do not change this adapter's direct API-key authentication. Failed connections dispose the SDK client.
Session-resumption updates are applied before content from the same server message is emitted. Continue consuming Output between turns so later control updates can be received before suspending.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Google.GenAI (>= 2.0.0)
- Universal.Operative.Sdk.Realtime (>= 2.2.0)
-
net8.0
- Google.GenAI (>= 2.0.0)
- Universal.Operative.Sdk.Realtime (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updates dependency to Universal.Operative.Sdk.Realtime 2.2.0.