Universal.Operative.Sdk.Realtime.xAI 1.0.0

dotnet add package Universal.Operative.Sdk.Realtime.xAI --version 1.0.0
                    
NuGet\Install-Package Universal.Operative.Sdk.Realtime.xAI -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Universal.Operative.Sdk.Realtime.xAI" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Universal.Operative.Sdk.Realtime.xAI" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Universal.Operative.Sdk.Realtime.xAI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Universal.Operative.Sdk.Realtime.xAI --version 1.0.0
                    
#r "nuget: Universal.Operative.Sdk.Realtime.xAI, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Universal.Operative.Sdk.Realtime.xAI@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Universal.Operative.Sdk.Realtime.xAI&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Universal.Operative.Sdk.Realtime.xAI&version=1.0.0
                    
Install as a Cake Tool

About

Universal.Operative.Sdk.Realtime.xAI adapts xAI's Grok Voice Agent API to Universal.Operative.Sdk.Realtime's provider-neutral IModel/IRealtimeSession/SessionEvent model.

Grok's Voice Agent implements the OpenAI Realtime API's core events verbatim (session.update, input_audio_buffer.append, response.create, conversation.item.create, ...), so this adapter reuses Universal.OpenAI.Realtime.Client's event DTOs and polymorphic (de)serialization directly. It does not reuse RealtimeClient itself, since its ConnectAsync overloads are hardcoded to wss://api.openai.com with no endpoint override -- the WebSocket connection to wss://api.x.ai/v1/realtime is hand-rolled against the same wire types.

How to Use

Installation

dotnet add package Universal.Operative.Sdk
dotnet add package Universal.Operative.Sdk.Realtime
dotnet add package Universal.Operative.Sdk.Realtime.xAI

Quick start

using Universal.Operative.Sdk.Realtime;
using Universal.Operative.Sdk.Realtime.xAI;

var model = new Model(apiKey, modelId: "grok-voice-latest");

IRealtimeSession session = await model.ConnectAsync(new RealtimeSessionOptions
{
    SystemPrompt = [new TextBlock("You are a helpful voice assistant.")],
    Tools = [myTool],
});

await foreach (SessionOutputEvent e in session.Output)
{
    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 by default) */ break;
        case InterruptedEvent: /* stop playback immediately */ break;
    }
}

await session.SendAsync(new AppendAudioInputEvent { Audio = micChunk });

Fidelity notes

  • Capabilities: AudioInProcess | ToolCalling | Transcripts -- xAI documents a resumption session parameter for context caching across reconnects, but it isn't wired up (no NativeResumption/ClientAssistedResumption).
  • Voice default: Model's defaultVoice parameter is null unless you supply one, leaving the choice to xAI's own server-side default.
  • Transcription default: GrokRealtimeSessionOptions.InputTranscription defaults to xAI's own "grok-transcribe" model.
  • Known gap: xAI documents a conversation.item.input_audio_transcription.updated event (a cumulative transcript, specific to "grok-transcribe") with no OpenAI counterpart. The vendor event DTOs this adapter reuses don't recognize it, so it surfaces as a RawPassthroughEvent rather than a canonical TranscriptDeltaEvent.
  • Tool results: the full ToolResult content is flattened into xAI's single-string function_call_output, same as the OpenAI adapter.
  • Tool choice: RealtimeSessionOptions.ToolChoice is sent the same way as the OpenAI adapter.
  • Mid-session reconfiguration: xAI mirrors OpenAI's session.update at the JSON level. This adapter recognizes RawSendEvent for it the same way the OpenAI adapter does: a constructed SessionUpdateEvent as Payload, or a {"type":"session.update",...} RawJson string.
  • Known gap: cross-modal text sent before any audio gets no response at all. Priming with a spoken audio turn first works for a standalone turn, but a full round trip that also waits for the priming turn's own completion can hang with no response and no error.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 41 8/12/2026

xAI Grok Voice Agent adapter for Universal.Operative.Sdk.Realtime. Grok's Voice Agent API implements the OpenAI Realtime protocol nearly verbatim, so this adapter reuses Universal.OpenAI.Realtime.Client's event DTOs directly; the WebSocket connection to wss://api.x.ai/v1/realtime is hand-rolled against those same wire types.