RealtimeAPIClient
Methods
addEventListener
addEventListener(event: , 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
event:
Event class (i.e., OpenAI.Beta.RealtimeAPIEvents.Error)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
close
close(): void
Closes the RealtimeAPIClient connection (over WebSocket) or connection attempt.
Returns
type:
void
id
id(): string
Returns the RealtimeAPIClient id.
Returns
type:
string
removeEventListener
removeEventListener(event: , callback: Function
): void
Removes a handler for the specified OpenAI.Beta.RealtimeAPIEvents event.
Parameters
event:
Event class (i.e., OpenAI.Beta.RealtimeAPIEvents.Error)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
responseCancel
responseCancel(eventId: string
): void
Cancels an in-progress response (https://platform.openai.com/docs/api-reference/realtime-client-events/response/cancel).
Parameters
eventId:
string
OptionalOptional. Client-generated ID used to identify this event
Returns
type:
void
responseCreate
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
OptionalOptional. Client-generated ID used to identify this event
Returns
type:
void
sendMediaTo
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the RealtimeAPIClient (via WebSocket) to the media unit. RealtimeAPIClient works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
sessionUpdate
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
OptionalOptional. Client-generated ID used to identify this event
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the RealtimeAPIClient (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
webSocketId
webSocketId(): string
Returns the RealtimeAPIClient WebSocket id.
Returns
type:
string