Rate this page:

RealtimeAPIClient

Methods

addEventListener

Copy URL
addEventListener(event: 

RealtimeAPIEvents

,
callback:

Function

):

void

Adds a handler for the specified OpenAI.Beta.RealtimeAPIEvents event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.

Parameters

Returns

  • type:

    void

close

Copy URL
close(): 

void

Closes the RealtimeAPIClient connection (over WebSocket) or connection attempt.

Returns

  • type:

    void

conversationItemCreate

Copy URL
conversationItemCreate(previousItemId: 

string

,
item:

Object

,
eventId:

string

):

void

Add a new Item to the Conversation's context, including messages, function calls, and function call responses. https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/create.

Returns

  • type:

    void

conversationItemDelete

Copy URL
conversationItemDelete(itemId: 

string

,
eventId:

string

):

void

Send this event when you want to remove any item from the conversation history. https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/delete.

Parameters

Returns

  • type:

    void

conversationItemTruncate

Copy URL
conversationItemTruncate(itemId: 

string

,
contentIndex:

number

,
audioEndMs:

number

,
eventId:

string

):

void

Send this event to truncate a previous assistant message’s audio. https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/truncate.

Returns

  • type:

    void

id

Copy URL
id(): 

string

Returns the RealtimeAPIClient id.

Returns

  • type:

    string

removeEventListener

Copy URL
removeEventListener(event: 

RealtimeAPIEvents

,
callback:

Function

):

void

Removes a handler for the specified OpenAI.Beta.RealtimeAPIEvents event.

Parameters

Returns

  • type:

    void

responseCancel

Copy URL
responseCancel(eventId: 

string

):

void

Parameters

Returns

  • type:

    void

responseCreate

Copy URL
responseCreate(response: 

Object

,
eventId:

string

):

void

Instructs the server to create a Response, which means triggering model inference. https://platform.openai.com/docs/api-reference/realtime-client-events/response/create.

Parameters

Returns

  • type:

    void

sendMediaTo

Copy URL
sendMediaTo(mediaUnit: 

VoxMediaUnit

,
parameters:

SendMediaParameters

):

void

Starts sending media from the RealtimeAPIClient (via WebSocket) to the media unit. RealtimeAPIClient works in real time.

Parameters

Returns

  • type:

    void

sessionUpdate

Copy URL
sessionUpdate(session: 

Object

,
eventId:

string

):

void

Parameters

Returns

  • type:

    void

stopMediaTo

Copy URL
stopMediaTo(mediaUnit: 

VoxMediaUnit

):

void

Stops sending media from the RealtimeAPIClient (via WebSocket) to the media unit.

Parameters

Returns

  • type:

    void

webSocketId

Copy URL
webSocketId(): 

string

Returns the RealtimeAPIClient WebSocket id.

Returns

  • type:

    string