Language

ProjectsRealtimeSessionClient Class

Definition

Realtime session client, using bearer token authentication.

public class ProjectsRealtimeSessionClient : OpenAI.Realtime.RealtimeSessionClient
type ProjectsRealtimeSessionClient = class
    inherit RealtimeSessionClient
Public Class ProjectsRealtimeSessionClient
Inherits RealtimeSessionClient
Inheritance
OpenAI.Realtime.RealtimeSessionClient
ProjectsRealtimeSessionClient

Remarks

This type extends OpenAI's OpenAI.Realtime.RealtimeSessionClient so that voice-agent sessions reuse its command and event model (for example OpenAI.Realtime.RealtimeSessionClient.SendInputAudioAsync(System.BinaryData,System.Threading.CancellationToken), OpenAI.Realtime.RealtimeSessionClient.AddItemAsync(OpenAI.Realtime.RealtimeItem,System.String,System.Threading.CancellationToken), or OpenAI.Realtime.RealtimeSessionClient.ReceiveUpdatesAsync(System.Threading.CancellationToken) for OpenAI's strongly-typed OpenAI.Realtime.RealtimeServerUpdate sequence). Only the query string/header values are Foundry-specific here (see the ConnectAsync(String, IDictionary<String,String>, CancellationToken) override below); the WebSocket handshake itself is performed by the base OpenAI.Realtime.RealtimeSessionClient.ConnectAsync(System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Threading.CancellationToken) implementation, targeting the Foundry voice-agent endpoint (/agents/{agentName}/endpoint/protocols/voice) this instance was constructed with instead of OpenAI's generic /realtime endpoint. Use StartSessionAsync(String, String, RealtimeSessionClientOptions, CancellationToken) (via ProjectsRealtimeClient) to obtain an already-connected instance.

Constructors

Name Description
ProjectsRealtimeSessionClient()

Internal empty constructor for mocking.

Methods

Name Description
ConnectAsync(String, IDictionary<String,String>, CancellationToken)

Connects to the Foundry voice-agent endpoint this instance was constructed with. Only the Foundry-specific query string (api-version, merged with any caller-supplied query string -- see queryString -- such as ProjectsRealtimeClient.StartSessionAsync's "store" option) and headers (Foundry-Features, bearer Authorization) are computed here; the WebSocket handshake itself (subprotocol negotiation, applying the headers, connecting, assigning OpenAI.Realtime.RealtimeSessionClient.WebSocket) is entirely delegated to OpenAI.Realtime.RealtimeSessionClient.ConnectAsync(System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Threading.CancellationToken).

Applies to