RealtimeAPIClient
Methods
addEventListener
addEventListener(event: | , 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
event:
Event class (i.e., OpenAI.RealtimeAPIEvents.SessionCreated)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
clearMediaBuffer
clearMediaBuffer(parameters: ): void
Clears the OpenAI WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
close
close(): void
Closes the OpenAI connection (over WebSocket) or connection attempt.
Returns
type:
void
conversationItemCreate
conversationItemCreate(parameters: Object
): void
Add a new Item to the Conversation's context. https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/create
Parameters
parameters:
Object
Returns
type:
void
conversationItemDelete
conversationItemDelete(parameters: Object
): 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
parameters:
Object
Returns
type:
void
conversationItemRetrieve
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://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/retrieve
Parameters
parameters:
Object
Returns
type:
void
conversationItemTruncate
conversationItemTruncate(parameters: Object
): 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
Parameters
parameters:
Object
Returns
type:
void
id
id(): string
Returns the RealtimeAPIClient id.
Returns
type:
string
inputAudioBufferClear
inputAudioBufferClear(parameters: Object
): void
Send this event to clear the audio bytes in the buffer. https://platform.openai.com/docs/api-reference/realtime-client-events/input_audio_buffer/clear
Parameters
parameters:
Object
Returns
type:
void
removeEventListener
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified OpenAI.RealtimeAPIEvents or OpenAI.Events event.
Parameters
event:
Event class (i.e., OpenAI.RealtimeAPIEvents.SessionCreated)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
responseCancel
responseCancel(parameters: Object
): void
Send this event to cancel an in-progress response. https://platform.openai.com/docs/api-reference/realtime-client-events/response/cancel
Parameters
parameters:
Object
Returns
type:
void
responseCreate
responseCreate(parameters: Object
): void
This event 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
parameters:
Object
Returns
type:
void
sendMediaTo
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the OpenAI (via WebSocket) to the media unit. OpenAI works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
sessionUpdate
sessionUpdate(parameters: Object
): void
Send this event to update the session’s configuration. https://platform.openai.com/docs/api-reference/realtime-client-events/session/update
Parameters
parameters:
Object
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the OpenAI (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
webSocketId
webSocketId(): string
Returns the OpenAI WebSocket id.
Returns
type:
string