Experimental
Experimental
Establishes a connection to the specified model with the given configuration and returns a Session object representing that connection.
The parameters for establishing a connection to the model.
A live session.
const session = await ai.live.connect({
model: 'gemini-2.0-flash-exp',
config: {
responseModalities: [Modality.AUDIO],
},
callbacks: {
onopen: () => {
console.log('Connected to the socket.');
},
onmessage: (e: MessageEvent) => {
console.log('Received message from the server: %s\n', debug(e.data));
},
onerror: (e: ErrorEvent) => {
console.log('Error occurred: %s\n', debug(e.error));
},
onclose: (e: CloseEvent) => {
console.log('Connection closed.');
},
},
});
Live class encapsulates the configuration for live interaction with the Generative Language API. It embeds ApiClient for general API settings.