LiveAPIClient
Constructors
Methods
addEventListener(event: | , callback: Function
): void
Adds a handler for the specified OpenAI.LiveAPIEvents 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.LiveAPIEvents.SessionStarted)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
close(): void
Closes the OpenAI connection (over WebSocket) or connection attempt.
Returns
type:
void
id(): string
Returns the LiveAPIClient id.
Returns
type:
string
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified OpenAI.LiveAPIEvents or OpenAI.Events event.
Parameters
event:
Event class (i.e., OpenAI.LiveAPIEvents.SessionStarted)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
responseCreate(parameters: Object
): void
Request a response from the Live session's Responses backend, or continue a delegated response that is waiting for tool results. Requires Responses delegation. This does not grant the voice model permission to speak. https://developers.openai.com/api/reference/resources/live/primary-websocket#response.create
Parameters
parameters:
Object
Event parameters
Returns
type:
void
responseItemCreate(parameters: Object
): void
Add an input item to the Live session's Responses backend, such as a function_call_output. Requires Responses delegation. Send OpenAI.LiveAPIClient.responseCreate after the required results to continue backend work. https://developers.openai.com/api/reference/resources/live/primary-websocket#response.item.create
Parameters
parameters:
Object
Event parameters
Returns
type:
void
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the OpenAI Live session (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
sessionClose(parameters: Object
): void
Request that the Live session close. The terminal OpenAI.LiveAPIEvents.SessionClosed event contains the close reason and final usage. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.close
Parameters
parameters:
Object
OptionalOptional. Event parameters
Returns
type:
void
sessionCommentaryAppend(parameters: Object
): void
Append a verified result the user should hear. Always include delegation_id (null for session-wide context). Content is a plain string of at most 500 tokens. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.commentary.append
Parameters
parameters:
Object
Event parameters
Returns
type:
void
sessionInputAudioMute(parameters: Object
): void
Mute audio input to the Live model without closing the session. Muting input does not stop the assistant's output. The server acknowledges with OpenAI.LiveAPIEvents.SessionInputAudioMuted. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.input_audio.mute
Parameters
parameters:
Object
OptionalOptional. Event parameters
Returns
type:
void
sessionInputAudioUnmute(parameters: Object
): void
Unmute audio input so it is sent to the Live model again. The server acknowledges with OpenAI.LiveAPIEvents.SessionInputAudioUnmuted. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.input_audio.unmute
Parameters
parameters:
Object
OptionalOptional. Event parameters
Returns
type:
void
sessionInstructionsAppend(parameters: Object
): void
Append instructions to the Live conversation while it is running. Always include delegation_id (null for session-wide context). Content is a plain string of at most 500 tokens. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.instructions.append
Parameters
parameters:
Object
Event parameters
Returns
type:
void
sessionStart(parameters: Object
): void
Start a Live session. Send this as the first custom event after OpenAI.createLiveAPIClient. Wait for OpenAI.LiveAPIEvents.SessionStarted before sending media or other commands. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.start
Parameters
parameters:
Object
Event parameters
Returns
type:
void
sessionThinkingAppend(parameters: Object
): void
Provide silent reasoning or progress context to the Live model. Always include delegation_id (null for session-wide context). Content is a plain string of at most 500 tokens. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.thinking.append
Parameters
parameters:
Object
Event parameters
Returns
type:
void
sessionUpdate(parameters: Object
): void
Update the delegation settings of an active Live session. The server acknowledges accepted changes with OpenAI.LiveAPIEvents.SessionUpdated. https://developers.openai.com/api/reference/resources/live/primary-websocket#session.update
Parameters
parameters:
Object
Event parameters
Returns
type:
void
stopMediaTo(mediaUnit: ): void
Stops sending media from the OpenAI Live session (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