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
<PackageReference Include="Universal.Operative.Sdk.Realtime.xAI" Version="1.0.0" />
<PackageVersion Include="Universal.Operative.Sdk.Realtime.xAI" Version="1.0.0" />
<PackageReference Include="Universal.Operative.Sdk.Realtime.xAI" />
paket add Universal.Operative.Sdk.Realtime.xAI --version 1.0.0
#r "nuget: Universal.Operative.Sdk.Realtime.xAI, 1.0.0"
#:package Universal.Operative.Sdk.Realtime.xAI@1.0.0
#addin nuget:?package=Universal.Operative.Sdk.Realtime.xAI&version=1.0.0
#tool nuget:?package=Universal.Operative.Sdk.Realtime.xAI&version=1.0.0
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 aresumptionsession parameter for context caching across reconnects, but it isn't wired up (noNativeResumption/ClientAssistedResumption). - Voice default:
Model'sdefaultVoiceparameter isnullunless you supply one, leaving the choice to xAI's own server-side default. - Transcription default:
GrokRealtimeSessionOptions.InputTranscriptiondefaults to xAI's own"grok-transcribe"model. - Known gap: xAI documents a
conversation.item.input_audio_transcription.updatedevent (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 aRawPassthroughEventrather than a canonicalTranscriptDeltaEvent. - Tool results: the full
ToolResultcontent is flattened into xAI's single-stringfunction_call_output, same as the OpenAI adapter. - Tool choice:
RealtimeSessionOptions.ToolChoiceis sent the same way as the OpenAI adapter. - Mid-session reconfiguration: xAI mirrors OpenAI's
session.updateat the JSON level. This adapter recognizesRawSendEventfor it the same way the OpenAI adapter does: a constructedSessionUpdateEventasPayload, or a{"type":"session.update",...}RawJsonstring. - 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 | 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. |
-
net10.0
- Universal.OpenAI.Client (>= 4.4.2)
- Universal.OpenAI.Realtime.Client (>= 1.0.3)
- Universal.Operative.Sdk (>= 5.0.0)
- Universal.Operative.Sdk.Realtime (>= 1.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.
| 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.