Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore
11.2.0
dotnet add package Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore --version 11.2.0
NuGet\Install-Package Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore -Version 11.2.0
<PackageReference Include="Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore" Version="11.2.0" />
<PackageVersion Include="Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore" Version="11.2.0" />
<PackageReference Include="Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore" />
paket add Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore --version 11.2.0
#r "nuget: Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore, 11.2.0"
#:package Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore@11.2.0
#addin nuget:?package=Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore&version=11.2.0
#tool nuget:?package=Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore&version=11.2.0
Ai.Tlbx.VoiceAssistant.Provider.OpenAi.AspNetCore
ASP.NET Core integration and static browser assets for direct OpenAI Realtime and GPT-Live WebRTC sessions.
The package keeps OpenAI API keys and voice tools on the server while sending microphone and playback audio directly between the browser and OpenAI.
GPT-Live setup (11.0.2+)
builder.Services.AddOpenAiDirectLiveVoice(options =>
{
options.AuthorizeRequest = context => context.User.Identity?.IsAuthenticated == true;
});
app.MapOpenAiDirectLiveVoice();
Inject OpenAiDirectLiveVoiceProvider in an interactive Blazor component and call
StartBrowserSessionAsync(new OpenAiLiveSettings { Instructions = "Help the caller." })
from a user gesture. Subscribe to OnTranscriptDelta and OnUsageReceived before starting.
Call DisconnectAsync to confirm final usage and release browser media.
Live uses a server-side JSON SDP exchange and an authenticated sideband. Tool execution and usage come from that trusted sideband; reflected audio is discarded. Settings and registered tools are prepared server-side, with a short-lived one-use handshake capability. Authorize session preparation as well as the endpoint. The existing Realtime setup below uses its own protocol and provider.
See the GPT-Live guide for managed/client delegation, microphone and
playback controls, history, lifecycle behavior and the /gpt-live demo.
Blazor Server setup
builder.Services.AddScoped<OpenAiDirectRealtimeVoiceProvider>();
builder.Services.AddOpenAiDirectRealtimeVoice(options =>
{
options.AuthorizeRequest = context => context.User.Identity?.IsAuthenticated == true;
});
app.UseWebSockets();
app.MapOpenAiDirectRealtimeVoice();
Use OpenAiDirectRealtimeVoiceProvider with the normal VoiceAssistant orchestrator:
var provider = serviceProvider.GetRequiredService<OpenAiDirectRealtimeVoiceProvider>();
var assistant = new VoiceAssistant(audioHardware, provider);
await assistant.StartAsync(new OpenAiVoiceSettings
{
Instructions = "You are helpful."
});
For OpenAI voice sessions in Blazor Server this keeps the public VoiceAssistant.StartAsync(settings) workflow intact while moving microphone capture and assistant playback off the Blazor circuit. The server still mints ephemeral OpenAI client secrets and executes IVoiceTool calls.
Tool preamble modes
Direct WebRTC applies non-default ToolCallPreambleMode values through Realtime instructions when AppendToolCallPreambleInstructions is true (the default). Those modes guide when the model emits a spoken tool bridge while preserving the low-latency remote media stream.
Set OpenAiVoiceSettings.AppendToolCallPreambleInstructions = false in the session factory to send Instructions exactly as supplied, including whitespace. The application then owns tool-call speech rules and response language; the selected ToolCallPreambleMode and audio/event delivery remain unchanged. Reconnect to apply new server-side settings to a Direct WebRTC session.
With augmentation enabled, ToolCallPreambleMode.Disabled is accepted as a strong model instruction, but it is not a deterministic audio gate. Both Direct WebRTC and the WebSocket provider forward received audio immediately to preserve low latency; applications that require strict phase filtering must enforce it outside the remote media stream.
Connection status
The browser client reports explicit connection phases through the regular status callback, including server session preparation, control WebSocket opening, microphone permission, WebRTC offer creation, OpenAI connection, DataChannel opening, and listening state.
Realtime usage events
After each response.done, the browser forwards the response ID, model ID, and OpenAI usage object to the authenticated control WebSocket as a client event with type usage. If input transcription is enabled, each conversation.item.input_audio_transcription.completed event is forwarded separately with type transcription_usage, its item/content identity, and the ASR usage object because OpenAI bills that model separately from the conversational Realtime response. Hosts can process both event types in IOpenAiDirectRealtimeSessionEventSink.OnClientEventAsync to keep an idempotent cost ledger and apply application budgets. The usage numbers originate in OpenAI's events, but the forwarding path still depends on the connected browser and should be identified as client-forwarded in audit reports.
Shared instruction composition
Browser session creation uses OpenAiInstructionsComposer.Compose(OpenAiVoiceSettings),
the same deterministic composer as OpenAiVoiceProvider. Set
ToolCallPreambleInstructionsOverride for an application-localized preamble, or
AppendToolCallPreambleInstructions = false to preserve the application instructions
exactly. Repeated composition does not mutate settings or duplicate additions. The
WebSocket provider's protocol callbacks and requested/sent/server-returned snapshot
properties are not browser data-channel observability APIs.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
-
net10.0
- Ai.Tlbx.VoiceAssistant (>= 11.2.0)
- Ai.Tlbx.VoiceAssistant.Provider.OpenAi (>= 11.2.0)
-
net9.0
- Ai.Tlbx.VoiceAssistant (>= 11.2.0)
- Ai.Tlbx.VoiceAssistant.Provider.OpenAi (>= 11.2.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 |
|---|---|---|
| 11.2.0 | 0 | 9/14/2026 |
| 11.1.0 | 29 | 9/14/2026 |
| 11.0.4 | 55 | 9/11/2026 |
| 11.0.3 | 48 | 9/11/2026 |
| 11.0.2 | 50 | 9/11/2026 |
| 11.0.1 | 45 | 9/11/2026 |
| 11.0.0 | 36 | 9/11/2026 |
| 10.8.2 | 51 | 9/10/2026 |
| 10.8.1 | 41 | 9/10/2026 |
| 10.8.0 | 44 | 9/9/2026 |
| 10.7.0 | 105 | 8/27/2026 |
| 10.6.0 | 99 | 8/26/2026 |
| 10.5.1 | 101 | 8/24/2026 |
| 10.5.0 | 105 | 8/22/2026 |
| 10.4.0 | 173 | 8/12/2026 |
| 10.3.0 | 100 | 8/5/2026 |
| 10.2.0 | 113 | 7/28/2026 |
| 10.1.2 | 186 | 7/19/2026 |
| 10.1.1 | 104 | 7/19/2026 |
| 10.1.0 | 114 | 7/16/2026 |