RealtimeTransportLayer
The transport layer is the layer that handles the connection to the model and the communication with the model.
Extends
Section titled “Extends”EventEmitter
<RealtimeTranportEventTypes
>
Properties
Section titled “Properties”readonly muted: null | boolean;
Whether the input audio track is currently muted null if the muting is not handled by the transport layer
status
Section titled “status”status: "connecting" | "connected" | "disconnected" | "disconnecting";
Methods
Section titled “Methods”close()
Section titled “close()”close(): void
Closes the connection to the model
Returns
Section titled “Returns”void
connect()
Section titled “connect()”connect(options): Promise<void>
Establishes the connection to the model and keeps the connection alive
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
The options for the connection |
Returns
Section titled “Returns”Promise
<void
>
emit()
Section titled “emit()”emit<K>(type, ...args): boolean
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
|
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
… |
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”EventEmitter.emit
interrupt()
Section titled “interrupt()”interrupt(): void
Interrupts the current turn. Used for example when a guardrail is triggered
Returns
Section titled “Returns”void
mute()
Section titled “mute()”mute(muted): void
Mutes the input audio track
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
|
Whether to mute the input audio track |
Returns
Section titled “Returns”void
off<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
|
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter
<RealtimeTranportEventTypes
>
Inherited from
Section titled “Inherited from”EventEmitter.off
on<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
|
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter
<RealtimeTranportEventTypes
>
Inherited from
Section titled “Inherited from”EventEmitter.on
once()
Section titled “once()”once<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
|
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter
<RealtimeTranportEventTypes
>
Inherited from
Section titled “Inherited from”EventEmitter.once
resetHistory()
Section titled “resetHistory()”resetHistory(oldHistory, newHistory): void
Resets the conversation history / context to a specific state
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
|
|
|
Returns
Section titled “Returns”void
sendAudio()
Section titled “sendAudio()”sendAudio(audio, options): void
Sends a raw audio buffer to the model
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
|
The audio buffer to send |
|
{ |
Additional options |
|
|
Whether to commit the audio buffer to the model. If the model does not do turn detection, this can be used to indicate the turn is completed. |
Returns
Section titled “Returns”void
sendEvent()
Section titled “sendEvent()”sendEvent(event): void
Sends a raw event to the model
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
The event to send |
Returns
Section titled “Returns”void
sendFunctionCallOutput()
Section titled “sendFunctionCallOutput()”sendFunctionCallOutput( toolCall, output, startResponse): void
Sends a function call output to the model
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
The tool call to send |
|
|
|
The output of the tool call |
|
|
‐ |
Returns
Section titled “Returns”void
sendMessage()
Section titled “sendMessage()”sendMessage(message, otherEventData): void
Sends a text message to the model
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
|
The message to send |
|
|
Additional event data, will be merged into the event |
Returns
Section titled “Returns”void
updateSessionConfig()
Section titled “updateSessionConfig()”updateSessionConfig(config): void
Sends an updated session configuration to the model. Used to update for example the model instructions during a handoff
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
|
|
The new session config |
Returns
Section titled “Returns”void