OpenAIRealtimeSIP
Transport layer that connects to an existing SIP-initiated Realtime call via call ID.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OpenAIRealtimeSIP(options): OpenAIRealtimeSIP;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”OpenAIRealtimeSIP
Overrides
Section titled “Overrides”OpenAIRealtimeWebSocket.constructor
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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket._tracingConfig
connectionState
Section titled “connectionState”Get Signature
Section titled “Get Signature”get connectionState(): WebSocketState;The current connection state of the WebSocket connection.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.connectionState
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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.currentModel
Get Signature
Section titled “Get Signature”get muted(): null;Always returns null as the WebSocket transport layer does not handle muting. Instead, this should be handled by the client by not triggering the sendAudio method.
Returns
Section titled “Returns”null
Whether the input audio track is currently muted null if the muting is not handled by the transport layer
Inherited from
Section titled “Inherited from”status
Section titled “status”Get Signature
Section titled “Get Signature”get status(): "connecting" | "connected" | "disconnected";The current status of the WebSocket connection.
Returns
Section titled “Returns”"connecting" | "connected" | "disconnected"
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.status
Methods
Section titled “Methods”_cancelResponse()
Section titled “_cancelResponse()”_cancelResponse(): void;Send a cancel response event to the Realtime API. This is used to cancel an ongoing response that the model is currently generating.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket._cancelResponse
_interrupt()
Section titled “_interrupt()”_interrupt(elapsedTime, cancelOngoingResponse): void;Do NOT call this method directly. Call interrupt() instead for proper interruption handling.
This method is used to send the right events to the API to inform the model that the user has interrupted the response. It might be overridden/extended by an extended transport layer. See the TwilioRealtimeTransportLayer for an example.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
|
| The elapsed time since the response started. |
|
|
|
| ‐ |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket._interrupt
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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.addImage
buildSessionPayload()
Section titled “buildSessionPayload()”buildSessionPayload(config): RealtimeSessionPayload;Build the payload object expected by the Realtime API when creating or updating a session.
The helper centralises the conversion from camelCase runtime config to the snake_case payload required by the Realtime API so transports that need a one-off payload (for example SIP call acceptance) can reuse the same logic without duplicating private state.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
|
| The session config to merge with defaults. |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.buildSessionPayload
close()
Section titled “close()”close(): void;Close the WebSocket connection.
This will also reset any internal connection tracking used for interruption handling.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”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>
Overrides
Section titled “Overrides”OpenAIRealtimeWebSocket.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
Inherited from
Section titled “Inherited from”interrupt()
Section titled “interrupt()”interrupt(cancelOngoingResponse): void;Interrupt the ongoing response. This method is triggered automatically by the client when voice activity detection (VAD) is enabled (default) as well as when an output guardrail got triggered.
You can also call this method directly if you want to interrupt the conversation for example based on an event in the client.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
|
|
|
|
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.interrupt
mute()
Section titled “mute()”mute(_muted): never;Will throw an error as the WebSocket transport layer does not support muting.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
Returns
Section titled “Returns”never
Inherited from
Section titled “Inherited from”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>
Inherited from
Section titled “Inherited from”on<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>
Inherited from
Section titled “Inherited from”once()
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>
Inherited from
Section titled “Inherited from”resetHistory()
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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.resetHistory
sendAudio()
Section titled “sendAudio()”sendAudio(_audio, _options): never;Send an audio buffer to the Realtime API. This is used for your client to send audio to the model to respond.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
| { |
|
|
|
Returns
Section titled “Returns”never
Overrides
Section titled “Overrides”OpenAIRealtimeWebSocket.sendAudio
sendEvent()
Section titled “sendEvent()”sendEvent(event): void;Send an event to the Realtime API. This will stringify the event and send it directly to the API. This can be used if you want to take control over the connection and send events manually.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
| The event to send. |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.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 | Default value | 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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.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
Inherited from
Section titled “Inherited from”OpenAIRealtimeWebSocket.updateSessionConfig
buildInitialConfig()
Section titled “buildInitialConfig()”static buildInitialConfig<TBaseContext>( agent, options,overrides): Promise<RealtimeSessionPayload>;Build the initial session payload for a SIP-attached session, matching the config that a RealtimeSession would send on connect.
This enables SIP deployments to accept an incoming call with a payload that already reflects the active agent’s instructions, tools, prompt, and tracing metadata without duplicating the session logic outside of the SDK. The returned object structurally matches the REST CallAcceptParams interface, so it can be forwarded directly to openai.realtime.calls.accept(...).
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
|
|
|
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
|
| | | The starting agent used to seed the session instructions, tools, and prompt. |
|
|
| Optional session options that mirror the ones passed to the RealtimeSession constructor. |
|
|
| Additional config overrides applied on top of the session options. |
Returns
Section titled “Returns”Promise<RealtimeSessionPayload>