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.

sessionStarted

Original startup event, including the persisted conversation ID when supplied by the service.

state

Current connection state.

Methods

appendCommentary(string, VoiceAgentLiveAppendOptions)

Adds text for the model to say to the user. This is context, not a user message.

appendInstructions(string, VoiceAgentLiveAppendOptions)

Adds instructions to the session, not a user message.

appendThinking(string, VoiceAgentLiveAppendOptions)

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.

configureSession(LiveSessionUpdateParams, VoiceAgentEventOptions)

Updates delegation backend settings and transcript triggers. The audio format, model, and delegation owner cannot change.

dispose()

Closes the session. Equivalent to close().

muteInputAudio(VoiceAgentEventOptions)

Stops the model from processing input audio. Live has no input buffer to commit or clear.

off<K>(K, VoiceAgentLiveEventHandler<K>)

Removes a previously registered listener.

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.

once<K>(K, VoiceAgentLiveEventHandler<K>)

Adds a listener that runs once.

requestResponse(VoiceAgentEventOptions)

Asks the Responses backend to respond. Requires Responses delegation.

send(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)

Sends a Live command. Do not send session.start; the service starts the session.

sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)

Sends raw audio in the configured input format, without a WAV or other file header.

sendEvent(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)

Alias for send().

sendResponseItem(Record<string, unknown>, VoiceAgentEventOptions)

Adds a conversation item when the session uses Responses delegation.

sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)

Sends a function result to the Responses backend and requests a follow-up response by default.

unmuteInputAudio(VoiceAgentEventOptions)

Resumes model audio input.

Inherited Methods

[asyncIterator]()

Property Details

closed

Resolves when the connection closes, with service confirmation and error details if available.

closed: Promise<VoiceAgentLiveCloseResult>

Property Value

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

Current connection state.

state: VoiceAgentConnectionState

Property Value

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

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

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

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

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

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

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

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

Returns

this

requestResponse(VoiceAgentEventOptions)

Asks the Responses backend to respond. Requires Responses delegation.

function requestResponse(options?: VoiceAgentEventOptions): Promise<void>

Parameters

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

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

Returns

Promise<void>

sendEvent(VoiceAgentLiveClientEvent, VoiceAgentSendOptions)

Alias for send().

function sendEvent(event: VoiceAgentLiveClientEvent, options?: VoiceAgentSendOptions): Promise<void>

Parameters

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>

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

Returns

Promise<void>

unmuteInputAudio(VoiceAgentEventOptions)

Resumes model audio input.

function unmuteInputAudio(options?: VoiceAgentEventOptions): Promise<void>

Parameters

Returns

Promise<void>

Inherited Method Details

[asyncIterator]()

function [asyncIterator](): AsyncIterator<VoiceAgentLiveEvent, any, any>

Returns

AsyncIterator<VoiceAgentLiveEvent, any, any>

Inherited From AsyncIterable.[asyncIterator]