Table of Contents

Class RealtimeSession

Namespace
OpenAI.Realtime
Assembly
OpenAI-DotNet.dll
public sealed class RealtimeSession : IDisposable
Inheritance
RealtimeSession
Implements
Inherited Members

Properties

Configuration

The configuration options for the session.

public SessionConfiguration Configuration { get; }

Property Value

SessionConfiguration

EnableDebug

Enable or disable logging.

public bool EnableDebug { get; set; }

Property Value

bool

EventTimeout

The timeout in seconds to wait for a response from the server.

public int EventTimeout { get; set; }

Property Value

int

Options

[Obsolete("Use RealtimeSession.Configuration")]
public SessionConfiguration Options { get; }

Property Value

SessionConfiguration

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~RealtimeSession()

protected ~RealtimeSession()

ReceiveUpdatesAsync<T>(Action<T>, CancellationToken)

Receive callback updates from the server

public Task ReceiveUpdatesAsync<T>(Action<T> sessionEvent, CancellationToken cancellationToken) where T : IRealtimeEvent

Parameters

sessionEvent Action<T>

The event to receive updates for.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task

Task.

Type Parameters

T

IRealtimeEvent to subscribe for updates to.

Exceptions

Exception

If ReceiveUpdatesAsync<T>(CancellationToken) is already running.

ReceiveUpdatesAsync<T>(CancellationToken)

Receive callback updates from the server

public IAsyncEnumerable<T> ReceiveUpdatesAsync<T>(CancellationToken cancellationToken) where T : IRealtimeEvent

Parameters

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

IAsyncEnumerable<T>

IAsyncEnumerable<T>.

Type Parameters

T

IRealtimeEvent to subscribe for updates to.

Exceptions

Exception

If ReceiveUpdatesAsync<T>(CancellationToken) is already running.

SendAsync<T>(T, Action<IServerEvent>, CancellationToken)

Send a client event to the server.

public Task<IServerEvent> SendAsync<T>(T @event, Action<IServerEvent> sessionEvents, CancellationToken cancellationToken = default) where T : IClientEvent

Parameters

event T

The event to send.

sessionEvents Action<IServerEvent>

Optional, Action<T>.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<IServerEvent>

Task<TResult>.

Type Parameters

T

IClientEvent to send to the server.

SendAsync<T>(T, CancellationToken)

Send a client event to the server.

public Task<IServerEvent> SendAsync<T>(T @event, CancellationToken cancellationToken = default) where T : IClientEvent

Parameters

event T

The event to send.

cancellationToken CancellationToken

Optional, CancellationToken.

Returns

Task<IServerEvent>

Task<TResult>.

Type Parameters

T

IClientEvent to send to the server.

Send<T>(T)

Send a client event to the server.

public void Send<T>(T @event) where T : IClientEvent

Parameters

event T

The event to send.

Type Parameters

T

IClientEvent to send to the server.