Rate this page:

RealtimeAPIClient

Constructors

constructor
Copy URL

Methods

addEventListener
Copy URL
addEventListener(event: 

Events

|

RealtimeAPIEvents

,
callback:

Function

):

void

Adds a handler for the specified OpenAI.Beta.RealtimeAPIEvents or OpenAI.Beta.Events 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

clearMediaBuffer
Copy URL
clearMediaBuffer(parameters: 

ClearMediaBufferParameters

):

void

Clears the RealtimeAPI WebSocket media buffer.

Parameters

Returns

  • type:

    void

close
Copy URL
close(): 

void

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

Returns

  • type:

    void

conversationItemCreate
Copy URL
conversationItemCreate(previousItemId: 

string

|
undefined
,
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.

Parameters

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

conversationItemRetrieve
Copy URL
conversationItemRetrieve(itemId: 

string

,
eventId:

string

):

void

Send this event when you want to retrieve the server's representation of a specific item in the conversation history. https://platform.openai.com/docs/api-reference/realtime_client_events/conversation/item/retrieve.

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: 

Events

|

RealtimeAPIEvents

,
callback:

Function

):

void

Removes a handler for the specified OpenAI.Beta.RealtimeAPIEvents or OpenAI.Beta.Events 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 RealtimeAPI (via WebSocket) to the media unit. RealtimeAPI 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 RealtimeAPI (via WebSocket) to the media unit.

Parameters

Returns

  • type:

    void

webSocketId
Copy URL
webSocketId(): 

string

Returns the RealtimeAPI WebSocket id.

Returns

  • type:

    string

Rate this page: