VoiceAgentLiveConnection interface
A GPT Live voice session.
Read events with one for await loop or use on, off, and once listeners.
Leaving the loop closes the session. Received audio chunks are base64 strings.
- Extends
-
AsyncIterable<VoiceAgentLiveEvent>
Properties
| closed | Resolves when the connection closes, with service confirmation and error details if available. |
| session | Latest session settings. Available as soon as connect() returns. |
| session |
Original startup event, including the persisted conversation ID when supplied by the service. |
| state | Current connection state. |
Methods
| append |
Adds text for the model to say to the user. This is context, not a user message. |
| append |
Adds instructions to the session, not a user message. |
| append |
Adds background context without asking the model to speak it. Do not use this to hide secrets. |
| close(number, string) | Closes the session and waits for service confirmation. Rejects if the connection failed or finalization was not confirmed, including when the socket has already closed. |
| configure |
Updates delegation backend settings and transcript triggers. The audio format, model, and delegation owner cannot change. |
| dispose() | Closes the session. Equivalent to close(). |
| mute |
Stops the model from processing input audio. Live has no input buffer to commit or clear. |
| off<K>(K, Voice |
Removes a previously registered listener. |
| on<K>(K, Voice |
Adds a listener for subsequent events. Use the connect option onEvent for startup events, or read sessionStarted for startup metadata. |
| once<K>(K, Voice |
Adds a listener that runs once. |
| request |
Asks the Responses backend to respond. Requires Responses delegation. |
| send(Voice |
Sends a Live command. Do not send session.start; the service starts the session. |
| send |
Sends raw audio in the configured input format, without a WAV or other file header. |
| send |
Alias for send(). |
| send |
Adds a conversation item when the session uses Responses delegation. |
| send |
Sends a function result to the Responses backend and requests a follow-up response by default. |
| unmute |
Resumes model audio input. |
Inherited Methods
| [async |
Property Details
closed
Resolves when the connection closes, with service confirmation and error details if available.
closed: Promise<VoiceAgentLiveCloseResult>
Property Value
Promise<VoiceAgentLiveCloseResult>
session
Latest session settings. Available as soon as connect() returns.
session: VoiceAgentLiveSessionResource
Property Value
sessionStarted
Original startup event, including the persisted conversation ID when supplied by the service.
sessionStarted: LiveServerEventLiveSessionStarted
Property Value
state
Method Details
appendCommentary(string, VoiceAgentLiveAppendOptions)
Adds text for the model to say to the user. This is context, not a user message.
function appendCommentary(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
Parameters
- content
-
string
- options
- VoiceAgentLiveAppendOptions
Returns
Promise<void>
appendInstructions(string, VoiceAgentLiveAppendOptions)
Adds instructions to the session, not a user message.
function appendInstructions(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
Parameters
- content
-
string
- options
- VoiceAgentLiveAppendOptions
Returns
Promise<void>
appendThinking(string, VoiceAgentLiveAppendOptions)
Adds background context without asking the model to speak it. Do not use this to hide secrets.
function appendThinking(content: string, options?: VoiceAgentLiveAppendOptions): Promise<void>
Parameters
- content
-
string
- options
- VoiceAgentLiveAppendOptions
Returns
Promise<void>
close(number, string)
Closes the session and waits for service confirmation. Rejects if the connection failed or finalization was not confirmed, including when the socket has already closed.
function close(code?: number, reason?: string): Promise<void>
Parameters
- code
-
number
- reason
-
string
Returns
Promise<void>
configureSession(LiveSessionUpdateParams, VoiceAgentEventOptions)
Updates delegation backend settings and transcript triggers. The audio format, model, and delegation owner cannot change.
function configureSession(session: LiveSessionUpdateParams, options?: VoiceAgentEventOptions): Promise<void>
Parameters
- session
- LiveSessionUpdateParams
- options
- VoiceAgentEventOptions
Returns
Promise<void>
dispose()
Closes the session. Equivalent to close().
function dispose(): Promise<void>
Returns
Promise<void>
muteInputAudio(VoiceAgentEventOptions)
Stops the model from processing input audio. Live has no input buffer to commit or clear.
function muteInputAudio(options?: VoiceAgentEventOptions): Promise<void>
Parameters
- options
- VoiceAgentEventOptions
Returns
Promise<void>
off<K>(K, VoiceAgentLiveEventHandler<K>)
Removes a previously registered listener.
function off<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
Parameters
- type
-
K
- handler
Returns
this
on<K>(K, VoiceAgentLiveEventHandler<K>)
Adds a listener for subsequent events. Use the connect option onEvent for startup events, or read sessionStarted for startup metadata.
function on<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
Parameters
- type
-
K
- handler
Returns
this
once<K>(K, VoiceAgentLiveEventHandler<K>)
Adds a listener that runs once.
function once<K>(type: K, handler: VoiceAgentLiveEventHandler<K>): this
Parameters
- type
-
K
- handler
Returns
this
requestResponse(VoiceAgentEventOptions)
Asks the Responses backend to respond. Requires Responses delegation.
function requestResponse(options?: VoiceAgentEventOptions): Promise<void>
Parameters
- options
- VoiceAgentEventOptions
Returns
Promise<void>
send(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)
Sends a Live command. Do not send session.start; the service starts the session.
function send(event: VoiceAgentLiveClientEvent, options?: VoiceAgentSendOptions): Promise<void>
Parameters
- options
- VoiceAgentSendOptions
Returns
Promise<void>
sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)
Sends raw audio in the configured input format, without a WAV or other file header.
function sendAudio(audio: ArrayBuffer | Uint8Array, options?: VoiceAgentEventOptions): Promise<void>
Parameters
- audio
-
ArrayBuffer | Uint8Array
- options
- VoiceAgentEventOptions
Returns
Promise<void>
sendEvent(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)
Alias for send().
function sendEvent(event: VoiceAgentLiveClientEvent, options?: VoiceAgentSendOptions): Promise<void>
Parameters
- options
- VoiceAgentSendOptions
Returns
Promise<void>
sendResponseItem(Record<string, unknown>, VoiceAgentEventOptions)
Adds a conversation item when the session uses Responses delegation.
function sendResponseItem(item: Record<string, unknown>, options?: VoiceAgentEventOptions): Promise<void>
Parameters
- item
-
Record<string, unknown>
- options
- VoiceAgentEventOptions
Returns
Promise<void>
sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)
Sends a function result to the Responses backend and requests a follow-up response by default.
function sendToolOutput(callId: string, output: string, options?: VoiceAgentSendToolOutputOptions): Promise<void>
Parameters
- callId
-
string
- output
-
string
- options
- VoiceAgentSendToolOutputOptions
Returns
Promise<void>
unmuteInputAudio(VoiceAgentEventOptions)
Resumes model audio input.
function unmuteInputAudio(options?: VoiceAgentEventOptions): Promise<void>
Parameters
- options
- VoiceAgentEventOptions
Returns
Promise<void>
Inherited Method Details
[asyncIterator]()
function [asyncIterator](): AsyncIterator<VoiceAgentLiveEvent, any, any>
Returns
AsyncIterator<VoiceAgentLiveEvent, any, any>
Inherited From AsyncIterable.[asyncIterator]