API Reference
Class
OpenAIRealtimeSession
Owns an active OpenAI Realtime WebSocket session.
Inheritance
- Object
- OpenAIRealtimeSession
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
Methods
public Task AppendAudioAsync(Byte[] audioBytes, CancellationToken cancellationToken = null) #Returns:
TaskAppends base64-encoded PCM audio bytes to the session input buffer.
Parameters
- audioBytes System.Byte[]
- cancellationToken System.Threading.CancellationToken = null
public async Task CloseAsync(CancellationToken cancellationToken = null) #Returns:
TaskCloses the Realtime WebSocket when possible.
Parameters
- cancellationToken System.Threading.CancellationToken = null
public async Task CommitAudioAsync(Boolean requestResponse = true, CancellationToken cancellationToken = null) #Returns:
TaskCommits the current input audio buffer and optionally asks the model to respond.
Parameters
- requestResponse System.Boolean = true
- cancellationToken System.Threading.CancellationToken = null
public async Task<OpenAIRealtimeEvent> ReceiveEventAsync(CancellationToken cancellationToken = null) #Returns:
Task<OpenAIRealtimeEvent>Receives the next complete Realtime server event. Only one receive operation may run at a time.
Parameters
- cancellationToken System.Threading.CancellationToken = null
public Task RequestResponseAsync(CancellationToken cancellationToken = null) #Returns:
TaskRequests a model response for the current conversation state.
Parameters
- cancellationToken System.Threading.CancellationToken = null
public async Task SendEventAsync(String eventJson, CancellationToken cancellationToken = null) #Returns:
TaskSends a raw Realtime client event.
Parameters
- eventJson System.String
- cancellationToken System.Threading.CancellationToken = null
public async Task SendImageAsync(String imageUrl, Boolean requestResponse = true, CancellationToken cancellationToken = null) #Returns:
TaskSends an image URL or data URL as a user input item and optionally asks the model to respond.
Parameters
- imageUrl System.String
- requestResponse System.Boolean = true
- cancellationToken System.Threading.CancellationToken = null
public async Task SendTextAsync(String text, Boolean requestResponse = true, CancellationToken cancellationToken = null) #Returns:
TaskSends a user text item and optionally asks the model to respond.
Parameters
- text System.String
- requestResponse System.Boolean = true
- cancellationToken System.Threading.CancellationToken = null