Skip to content

RealtimeTransportLayer

The transport layer is the layer that handles the connection to the model and the communication with the model.

readonly muted: null | boolean;

Whether the input audio track is currently muted null if the muting is not handled by the transport layer


status: "connecting" | "connected" | "disconnected" | "disconnecting";
close(): void

Closes the connection to the model

void


connect(options): Promise<void>

Establishes the connection to the model and keeps the connection alive

Parameter Type Description

options

RealtimeTransportLayerConnectOptions

The options for the connection

Promise<void>


emit<K>(type, ...args): boolean
Type Parameter

K extends keyof RealtimeTranportEventTypes

Parameter Type

type

K

args

RealtimeTranportEventTypes[K]

boolean

EventEmitter.emit

interrupt(): void

Interrupts the current turn. Used for example when a guardrail is triggered

void


mute(muted): void

Mutes the input audio track

Parameter Type Description

muted

boolean

Whether to mute the input audio track

void


off<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameter

K extends keyof RealtimeTranportEventTypes

Parameter Type

type

K

listener

(…args) => void

EventEmitter<RealtimeTranportEventTypes>

EventEmitter.off

on<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameter

K extends keyof RealtimeTranportEventTypes

Parameter Type

type

K

listener

(…args) => void

EventEmitter<RealtimeTranportEventTypes>

EventEmitter.on

once<K>(type, listener): EventEmitter<RealtimeTranportEventTypes>
Type Parameter

K extends keyof RealtimeTranportEventTypes

Parameter Type

type

K

listener

(…args) => void

EventEmitter<RealtimeTranportEventTypes>

EventEmitter.once

resetHistory(oldHistory, newHistory): void

Resets the conversation history / context to a specific state

Parameter Type

oldHistory

RealtimeItem[]

newHistory

RealtimeItem[]

void


sendAudio(audio, options): void

Sends a raw audio buffer to the model

Parameter Type Description

audio

ArrayBuffer

The audio buffer to send

options

{ commit: boolean; }

Additional options

options.commit?

boolean

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.

void


sendEvent(event): void

Sends a raw event to the model

Parameter Type Description

event

RealtimeClientMessage

The event to send

void


sendFunctionCallOutput(
toolCall,
output,
startResponse): void

Sends a function call output to the model

Parameter Type Description

toolCall

TransportToolCallEvent

The tool call to send

output

string

The output of the tool call

startResponse

boolean

void


sendMessage(message, otherEventData): void

Sends a text message to the model

Parameter Type Description

message

RealtimeUserInput

The message to send

otherEventData

Record<string, any>

Additional event data, will be merged into the event

void


updateSessionConfig(config): void

Sends an updated session configuration to the model. Used to update for example the model instructions during a handoff

Parameter Type Description

config

Partial<RealtimeSessionConfig>

The new session config

void