OpenAIRealtimeBase
此内容尚不支持你的语言。
The transport layer is the layer that handles the connection to the model and the communication with the model.
Extends
Section titled “Extends”EventEmitterDelegate<OpenAIRealtimeEventTypes>
Extended by
Section titled “Extended by”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OpenAIRealtimeBase(options?): OpenAIRealtimeBase;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”OpenAIRealtimeBase
Overrides
Section titled “Overrides”EventEmitterDelegate<OpenAIRealtimeEventTypes>.constructorProperties
Section titled “Properties”abstract readonly muted: boolean | null;Whether the input audio track is currently muted null if the muting is not handled by the transport layer
Implementation of
Section titled “Implementation of”Accessors
Section titled “Accessors”_tracingConfig
Section titled “_tracingConfig”Set Signature
Section titled “Set Signature”set _tracingConfig(tracingConfig): void;Sets the internal tracing config. This is used to track the tracing config that has been set during the session.create event.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”void
currentModel
Section titled “currentModel”Get Signature
Section titled “Get Signature”get currentModel(): OpenAIRealtimeModels;The current model that is being used by the transport layer.
Returns
Section titled “Returns”Set Signature
Section titled “Set Signature”set currentModel(model): void;The current model that is being used by the transport layer. Note: The model cannot be changed mid conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”void
status
Section titled “status”Get Signature
Section titled “Get Signature”get abstract status(): "connecting" | "connected" | "disconnected" | "disconnecting";Returns
Section titled “Returns”"connecting" | "connected" | "disconnected" | "disconnecting"
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”addImage()
Section titled “addImage()”addImage(image, options?): void;Sends an image to the model
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The image to send |
|
|
{ |
Additional options |
|
|
|
Whether to trigger a response from the model |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.addImage
close()
Section titled “close()”abstract close(): void;Closes the connection to the model
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”connect()
Section titled “connect()”abstract 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>
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.connect
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
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”EventEmitterDelegate.emitinterrupt()
Section titled “interrupt()”abstract interrupt(): void;Interrupts the current turn. Used for example when a guardrail is triggered
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.interrupt
mute()
Section titled “mute()”abstract 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
Implementation of
Section titled “Implementation of”off<K>(type, listener): EventEmitter<EventTypes>;Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter<EventTypes>
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”EventEmitterDelegate.offon<K>(type, listener): EventEmitter<EventTypes>;Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter<EventTypes>
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”EventEmitterDelegate.ononce()
Section titled “once()”once<K>(type, listener): EventEmitter<EventTypes>;Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
|
|
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
(… |
Returns
Section titled “Returns”EventEmitter<EventTypes>
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”EventEmitterDelegate.onceresetHistory()
Section titled “resetHistory()”resetHistory(oldHistory, newHistory): void;Reset the history of the conversation. This will create a diff between the old and new history and send the necessary events to the Realtime API to update the history.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The old history of the conversation. |
|
|
|
The new history of the conversation. |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.resetHistory
sendAudio()
Section titled “sendAudio()”sendAudio(audio, options?): void;Send an audio buffer to the Realtime API. If { commit: true } is passed, the audio buffer
will be committed and the model will start processing it. This is necessary if you have
disabled turn detection / voice activity detection (VAD).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The audio buffer to send. |
|
|
{ |
The options for the audio buffer. |
|
|
|
‐ |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.sendAudio
sendEvent()
Section titled “sendEvent()”abstract 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
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.sendEvent
sendFunctionCallOutput()
Section titled “sendFunctionCallOutput()”sendFunctionCallOutput( toolCall, output, startResponse?): void;Send the output of a function call to the Realtime API.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
The tool call to send the output for. |
|
|
|
|
The output of the function call. |
|
|
|
Whether to start a new response after sending the output. |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.sendFunctionCallOutput
sendMcpResponse()
Section titled “sendMcpResponse()”sendMcpResponse(approvalRequest, approved): void;Sends a response for an MCP tool call
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
{ |
The approval request to respond to |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
Whether the tool call was approved or rejected |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.sendMcpResponse
sendMessage()
Section titled “sendMessage()”sendMessage( message, otherEventData, __namedParameters?): void;Send a message to the Realtime API. This will create a new item in the conversation and trigger a response.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The message to send. |
|
|
|
Additional event data to send. |
|
|
{ |
‐ |
|
|
|
‐ |
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”RealtimeTransportLayer.sendMessage
updateSessionConfig()
Section titled “updateSessionConfig()”updateSessionConfig(config): void;Updates the session config. This will merge it with the current session config with the default values and send it to the Realtime API.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
|
The session config to update. |
Returns
Section titled “Returns”void