RealtimeAPIClient
Constructors
Methods
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(parameters: ): void
Clears the OpenAI WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
close(): void
Closes the OpenAI connection (over WebSocket) or connection attempt.
Returns
type:
void
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(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(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(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(): string
Returns the RealtimeAPIClient id.
Returns
type:
string
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(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(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(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(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(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
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
OptionalOptional. Event parameters
Returns
type:
void
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(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(): string
Returns the OpenAI WebSocket id.
Returns
type:
string