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

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

Cancels an in-progress response (https://platform.openai.com/docs/api-reference/realtime-client-events/response/cancel).

Parameters

  • eventId:

    string

    Optional

    Optional. Client-generated ID used to identify this event

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

  • response:

    Object

    The response resource (https://platform.openai.com/docs/api-reference/realtime-client-events/response/create#realtime-client-events/response/create-response). NOTE: the 'inputt_audio_format' parameter will be ignored

  • eventId:

    string

    Optional

    Optional. Client-generated ID used to identify this event

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

Updates the session’s default configuration (https://platform.openai.com/docs/api-reference/realtime-client-events/session/update).

Parameters

  • session:

    Object

    Realtime session object configuration (https://platform.openai.com/docs/api-reference/realtime-client-events/session/update#realtime-client-events/session/update-session). NOTE: the 'inputt_audio_format' parameter will be ignored

  • eventId:

    string

    Optional

    Optional. Client-generated ID used to identify this event

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