VoiceAgentWebSocketTransport interface

WebSocket transport used by Realtime and GPT Live. Implement this interface to connect through an authenticated relay or another custom transport.

Methods

close(number, string)

Closes the connection.

connect(VoiceAgentWebSocketConnectOptions)

Establishes the WebSocket connection.

send(string, AbortSignalLike)

Sends a message over the connection.

setHandlers(VoiceAgentWebSocketHandlers)

Registers the handlers invoked as connection events occur.

Method Details

close(number, string)

Closes the connection.

function close(code: number, reason: string): Promise<void>

Parameters

code

number

reason

string

Returns

Promise<void>

connect(VoiceAgentWebSocketConnectOptions)

Establishes the WebSocket connection.

function connect(options: VoiceAgentWebSocketConnectOptions): Promise<void>

Parameters

Returns

Promise<void>

send(string, AbortSignalLike)

Sends a message over the connection.

function send(data: string, abortSignal?: AbortSignalLike): Promise<void>

Parameters

data

string

abortSignal
AbortSignalLike

Returns

Promise<void>

setHandlers(VoiceAgentWebSocketHandlers)

Registers the handlers invoked as connection events occur.

function setHandlers(handlers: VoiceAgentWebSocketHandlers)

Parameters