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.RealtimeAPIEvents or OpenAI.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 OpenAI WebSocket media buffer.

Parameters

Returns

  • type:

    void

close
Copy URL
close(): 

void

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

Returns

  • type:

    void

conversationItemCreate
Copy URL
conversationItemCreate(parameters: 

Object

):

void

Add a new Item to the Conversation's context. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

conversationItemDelete
Copy URL
conversationItemDelete(parameters: 

Object

):

void

Send this event when you want to remove any item from the conversation history. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

conversationItemRetrieve
Copy URL
conversationItemRetrieve(parameters: 

Object

):

void

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

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

conversationItemTruncate
Copy URL
conversationItemTruncate(parameters: 

Object

):

void

Send this event to truncate a previous assistant message’s audio. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

id
Copy URL
id(): 

string

Returns the RealtimeAPIClient id.

Returns

  • type:

    string

inputAudioBufferClear
Copy URL
inputAudioBufferClear(parameters: 

Object

):

void

Send this event to clear the audio bytes in the buffer. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

inputAudioBufferCommit
Copy URL
inputAudioBufferCommit(parameters: 

Object

):

void

Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

removeEventListener
Copy URL
removeEventListener(event: 

Events

|

RealtimeAPIEvents

,
callback:

Function

):

void

Removes a handler for the specified OpenAI.RealtimeAPIEvents or OpenAI.Events event.

Parameters

Returns

  • type:

    void

responseCancel
Copy URL
responseCancel(parameters: 

Object

):

void

Send this event to cancel an in-progress response. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

responseCreate
Copy URL
responseCreate(parameters: 

Object

):

void

This event instructs the server to create a Response, which means triggering model inference. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

sendMediaTo
Copy URL
sendMediaTo(mediaUnit: 

VoxMediaUnit

,
parameters:

SendMediaParameters

):

void

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

Parameters

Returns

  • type:

    void

sessionClose
Copy URL
sessionClose(parameters: 

Object

):

void

Gracefully close a realtime translation session. The server flushes pending input audio and emits remaining output before sending OpenAI.RealtimeAPIEvents.SessionClosed. Supported for OpenAI.RealtimeAPIClientType.TRANSLATION. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Optional

    Optional. Event parameters

Returns

  • type:

    void

sessionUpdate
Copy URL
sessionUpdate(parameters: 

Object

):

void

Send this event to update the session’s configuration. https://developers.openai.com/api/reference/overview

Parameters

  • parameters:

    Object

    Event parameters

Returns

  • type:

    void

stopMediaTo
Copy URL
stopMediaTo(mediaUnit: 

VoxMediaUnit

):

void

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

Parameters

Returns

  • type:

    void

webSocketId
Copy URL
webSocketId(): 

string

Returns the OpenAI WebSocket id.

Returns

  • type:

    string

Rate this page: