Universal.OpenAI.Live.Client
1.0.0
See the version list below for details.
dotnet add package Universal.OpenAI.Live.Client --version 1.0.0
NuGet\Install-Package Universal.OpenAI.Live.Client -Version 1.0.0
<PackageReference Include="Universal.OpenAI.Live.Client" Version="1.0.0" />
<PackageVersion Include="Universal.OpenAI.Live.Client" Version="1.0.0" />
<PackageReference Include="Universal.OpenAI.Live.Client" />
paket add Universal.OpenAI.Live.Client --version 1.0.0
#r "nuget: Universal.OpenAI.Live.Client, 1.0.0"
#:package Universal.OpenAI.Live.Client@1.0.0
#addin nuget:?package=Universal.OpenAI.Live.Client&version=1.0.0
#tool nuget:?package=Universal.OpenAI.Live.Client&version=1.0.0
Universal.OpenAI.Live.Client
A .NET Standard 2.0 client for GPT-Live primary, sideband, and stored-session fork WebSockets. Includes typed audio, transcript, session, Responses delegation, Decisions, SIP progress, and error events. Uses shared session configuration and REST models from Universal.OpenAI.Client.V1.Live.
using Universal.OpenAI.Client.V1.Live;
using Universal.OpenAI.Live.Client;
using LiveSocket = Universal.OpenAI.Live.Client.LiveClient;
using var timeout = new CancellationTokenSource(TimeSpan.FromMinutes(2));
using var live = await LiveSocket.ConnectAsync(apiKey, new LiveSessionConfiguration
{
Instructions = "Help the caller. Delegate tasks that require tools.",
Audio = new LiveAudioConfiguration
{
Format = new LiveAudioFormat { Type = "audio/pcm", Rate = 24000 },
Output = new LiveAudioOutputConfiguration { Voice = "marin" }
},
Delegation = new LiveDelegationConfiguration { Type = "client" }
}, timeout.Token);
// ConnectAsync waits for session.started; Session contains the resolved configuration.
// Run the microphone producer concurrently with this single receive loop:
// await live.AppendAudioAsync(pcm16MonoChunk, timeout.Token);
await foreach (var entry in live.ReceiveEventsAsync(timeout.Token))
{
switch (entry)
{
case OutputAudioDeltaEvent audio:
await PlayAudioAsync(audio.GetAudioBytes()); // application audio playback
break;
case InputTranscriptDeltaEvent transcript:
Console.Write(transcript.Delta); // collect context; fragments are not full turns
break;
case DelegationCreatedEvent work when work.Delegation.Target == "client":
// Authorize and execute backend work in your application using saved transcript/task state.
var result = await RunBackendAsync(work.Delegation.Id);
await live.AppendCommentaryAsync(result, work.Delegation.Id, timeout.Token);
break;
case ErrorEvent error:
throw new LiveProtocolException(error.Error);
case SessionClosedEvent closed:
Console.WriteLine($"Closed: {closed.Reason}; seconds: {closed.Usage.Seconds}");
break;
}
}
PlayAudioAsync and RunBackendAsync above are application handlers. The library transports raw audio; it does not capture a microphone or drive speakers. PCM is mono signed 16-bit little endian at 16 or 24 kHz; G.711 PCMU/PCMA uses 8 kHz. Audio payloads contain no WAV header. Live performs turn handling continuously, without Realtime buffer-commit events. Primary output audio has no guaranteed timestamps or audio-done event.
Supply a continuous microphone stream paced at its sample rate, including silence while the microphone is quiet. Stopping input audio stops advancement of the Live audio timeline and can leave context appends pending. Stop producers between sends; cancelling an in-flight ClientWebSocket send or receive can abort its transport. PlayAudioFixtureAsync accepts a complete PCM16LE 24 kHz fixture of up to 30 seconds, regardless of the session format; microphone input during fixture playback is dropped.
To finish, call RequestCloseAsync while the receive loop runs and observe SessionClosedEvent. Its usage is cumulative. A transport disconnect is not confirmation of finalization. CloseAsync closes only the WebSocket; Dispose releases an owned socket. Unexpected remote close before session.closed throws. Cancellation propagates to the caller.
For Responses delegation, set Delegation.Type = "responses" and configure Responses.Model, instructions, and tools. ResponseEvent.Event uses the existing typed Responses streaming events, with an outer DelegationId. After your application executes a function, SubmitToolOutputAsync(callId, output) sends the result and resumes the backend. Client delegation is supported through thinking, commentary, and instruction appends; their delegation ID is serialized even when null. Decisions delegation, transcript triggers, item operations, and nested decision events are also supported. The library never executes tools automatically.
AttachAsync(apiKey, sessionId) attaches a trusted sideband without restarting or replaying a session. Sidebands receive reflected audio but cannot append input audio. Closing a sideband transport does not request session shutdown. ForkAsync(apiKey, storedSessionId, overrides) starts a new WebSocket session from a stored session without supplying a new model or voice.
OpenAIClient.V1.Live exposes WebRTC creation/SDP exchange, outbound SIP creation, inbound SIP accept/reject, transfer, hangup, recording download, and WebRTC forks. Pass LiveWebRtcTransport or LiveSipTransport to session creation. Outbound SIP requires your provider's trunk credentials and E.164 numbers; requests are not automatically retried. WebRTC media is handled by your application's peer connection, and SIP media by the provider.
One receive iterator may be active per connection; concurrent sends are serialized. LiveClientOptions controls the endpoint, startup timeout, message size limit, and WebSocket options. An open WebSocket can also be injected for testing or custom transport configuration. Unknown event types and additional fields are preserved.
Protocol references: primary WebSocket, sideband, fork, delegation, REST session creation.
Run offline tests with:
dotnet run --project CSharp/Universal.OpenAI.Live.Client.Tests -- --filter "TestCategory!=LiveInference"
Live validation reuses the existing API test credential through a linked source file. Set UNIVERSAL_OPENAI_LIVE_TESTS=1, then run with --filter "TestCategory=LiveInference". These tests create billable sessions and verify final session closure. They do not place telephone calls.
On November 9, 2026, sideband attachment to a primary WebSocket session returned HTTP 503; WebRTC sideband attachment succeeded. The optional primary-sideband compatibility probe requires UNIVERSAL_OPENAI_LIVE_PRIMARY_SIDEBAND_PROBE=1 in addition to the live-test flag. This service behavior does not affect primary audio, WebRTC sidebands, or stored-session forks.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Universal.OpenAI.Client (>= 4.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add GPT-Live WebSocket sessions, audio streaming, typed events, and backend delegation.