Class LiveExperimental

Live class encapsulates the configuration for live interaction with the Generative Language API. It embeds ApiClient for general API settings.

Constructors

Methods

Constructors

  • Experimental

    Parameters

    • apiClient: ApiClient
    • auth: Auth
    • webSocketFactory: WebSocketFactory

    Returns Live

Methods

  • Experimental

    Establishes a connection to the specified model with the given configuration and returns a Session object representing that connection.

    Parameters

    Returns Promise<Session>

    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.');
    },
    },
    });
MMNEPVFCICPMFPCPTTAAATR