Universal.Operative.Sdk.Realtime.xAI 2.0.0

dotnet add package Universal.Operative.Sdk.Realtime.xAI --version 2.0.0
                    
NuGet\Install-Package Universal.Operative.Sdk.Realtime.xAI -Version 2.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="2.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="2.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 2.0.0
                    
#r "nuget: Universal.Operative.Sdk.Realtime.xAI, 2.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@2.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=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Universal.Operative.Sdk.Realtime.xAI&version=2.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. The wire protocol itself comes from Universal.xAI.Realtime.Client.

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: Models.GrokVoiceLatest);

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 */ break;
    }
}

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

Provider-specific options

GrokRealtimeSessionOptions is a RealtimeSessionOptions subclass carrying the xAI-specific settings:

var options = new GrokRealtimeSessionOptions
{
    SystemPrompt = [new TextBlock("You are a helpful voice assistant.")],
    Voice = Voices.Eve,
    OutputAudioFormat = RealtimeAudioFormat.Pcm(RealtimeAudioSampleRates.Hz16000),
    OutputSpeed = 1.1,
    TurnDetection = new TurnDetection(TurnDetectionTypes.ServerVad) { IdleTimeoutMilliseconds = 8000 },
    InputTranscription = new RealtimeAudioTranscription { LanguageHint = LanguageHints.English, Keyterms = ["Grok"] },
    ReasoningEffort = ReasoningEfforts.None,
    Replace = new Dictionary<string, string> { ["Acme Mobile"] = "Acme Mobull" },
};

Setting InputAudioTransport/OutputAudioTransport to AudioTransports.Binary carries audio in WebSocket binary frames instead of base64 JSON. AppendAudioInputEvent and AudioOutputDeltaEvent are unchanged either way.

Behaviour notes

  • Capabilities: AudioInProcess | ToolCalling | Transcripts.
  • Turn detection: server_vad is the default. A null TurnDetection drives turns with CommitAudioInputEvent.
  • Transcripts: user transcripts arrive cumulatively as non-final TranscriptDeltaEvents, each superseding the last, then once as final. Assistant transcripts arrive once per turn, as final.
  • Message roles: SendTextInputEvent accepts user and assistant. MessageRoles.System throws; the system prompt belongs in RealtimeSessionOptions.SystemPrompt.
  • Tools: RealtimeSessionOptions.Tools maps to xAI function tools. xAI's server-side tools (web_search, x_search, file_search, mcp) are reachable through RawSendEvent with a constructed SessionUpdateEvent.
  • Tool results: ToolResult content is flattened into xAI's single-string function_call_output.
  • RawSendEvent: resolves its RawJson against every client event this adapter can send by matching the "type" field, or sends a constructed RealtimeClientEvent passed as Payload as-is.
  • Unmodelled server events: surface as RawPassthroughEvent with their payload intact.
Product 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. 
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
2.0.0 101 9/1/2026
1.3.0 104 8/26/2026
1.2.0 174 8/18/2026
1.1.0 105 8/18/2026
1.0.0 108 8/12/2026

Coordinated major release for Universal.Operative.Sdk 6 and the canonical provider-neutral tool-dispatch boundary.