Universal.Operative.Sdk.Realtime.Google.Gemini
3.0.0
See the version list below for details.
dotnet add package Universal.Operative.Sdk.Realtime.Google.Gemini --version 3.0.0
NuGet\Install-Package Universal.Operative.Sdk.Realtime.Google.Gemini -Version 3.0.0
<PackageReference Include="Universal.Operative.Sdk.Realtime.Google.Gemini" Version="3.0.0" />
<PackageVersion Include="Universal.Operative.Sdk.Realtime.Google.Gemini" Version="3.0.0" />
<PackageReference Include="Universal.Operative.Sdk.Realtime.Google.Gemini" />
paket add Universal.Operative.Sdk.Realtime.Google.Gemini --version 3.0.0
#r "nuget: Universal.Operative.Sdk.Realtime.Google.Gemini, 3.0.0"
#:package Universal.Operative.Sdk.Realtime.Google.Gemini@3.0.0
#addin nuget:?package=Universal.Operative.Sdk.Realtime.Google.Gemini&version=3.0.0
#tool nuget:?package=Universal.Operative.Sdk.Realtime.Google.Gemini&version=3.0.0
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).
Supports native session resumption and parallel tool-call correlation.
How to Use
Installation
dotnet add package Universal.Operative.Sdk.Realtime.Google.Gemini
Quick start
using Universal.Operative.Sdk;
using Universal.Operative.Sdk.Realtime;
using Universal.Operative.Sdk.Realtime.Google.Gemini;
Model model = new Model(apiKey, modelId: "gemini-2.5-flash-native-audio-preview-09-2025");
OperativeBuilder builder = OperativeBuilder.Create(new RealtimeSessionOptions { SystemPrompt = [new TextBlock("You are a helpful voice assistant.")], }).AddTool(myTool);
// apiKey, myTool, micChunk (16kHz mono PCM16) and cancellationToken come from the host.
await using IOperative operative = await builder.ConnectAsync(model, cancellationToken);
await operative.SendAsync(new AppendAudioInputEvent { Audio = micChunk }, cancellationToken);
await operative.SendAsync(new CommitAudioInputEvent(), cancellationToken);
await foreach (SessionOutputEvent e in operative.RunAsync(cancellationToken))
{
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 (operative.Session is IResumableSession resumable)
{
SessionHandle handle = await resumable.SuspendAsync(cancellationToken);
// ... later, possibly after a restart ...
await using IRealtimeSession resumed = await resumable.ResumeAsync(handle, cancellationToken);
}
Fidelity notes
- Capabilities:
AudioInProcess | ToolCalling | Transcripts | NativeResumption. - Tool results: text blocks contribute text verbatim and other blocks contribute serialized JSON; these strings are newline-joined into one string under
resultorerror. Block boundaries and types are not preserved in that string. - Async tool scheduling: add advertised tool names to
GoogleGeminiRealtimeSessionOptions.NonBlockingToolNamesto declare themNON_BLOCKING; other tools are explicitlyBLOCKING. Nonnull scheduling hints are accepted only for configured nonblocking names and map toFunctionResponse.Scheduling. The selected model must support asynchronous Live tools. Google's tool guide lists model-specific support, including no async tools for Gemini 3.1 Flash Live. Local tests establish request mapping, not remote scheduling behavior. - Barge-in and manual VAD: automatic server VAD is the default. With
RealtimeInputConfig.AutomaticActivityDetection.Disabled=true, the first audio chunk starts activity andCommitAudioInputEventends it; another chunk starts a new activity. With automatic VAD enabled, commit sendsAudioStreamEnd. These boundaries follow Google's Live protocol;InterruptRequestEventremains unsupported because it has no equivalent generation-cancel operation. - Tool choice:
RealtimeSessionOptions.ToolChoicethrowsNotSupportedException--Google.GenAI.Types.LiveConnectConfighas no tool-choice-equivalent field. - Raw passthrough: every provider message has a full
RawPassthroughEventcompanion, even when canonical events were emitted. This preserves mixed usage, media, control and content fields. Canonical references resolve into the companion with indexed JSON pointers and the same sequence. - 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. An update marking the state nonresumable or supplying an empty handle invalidates the previous handle; suspension then throws without closing. Continue consuming Output between turns so later control updates can be received before suspending.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net11.0 is compatible. |
-
net10.0
- Google.GenAI (>= 2.0.0)
- Universal.Operative.Sdk.Realtime (>= 3.0.0)
-
net11.0
- Google.GenAI (>= 2.0.0)
- Universal.Operative.Sdk.Realtime (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Targets .NET 10 and .NET 11; removes .NET 8 support. Validates required connection configuration immediately. Failed connection and owned-session/client cleanup retain original native failures and secondary context; client disposal still runs if session disposal fails.