React Native Firebase
    Preparing search index...

    Represents an active, real-time, bidirectional conversation with the model.

    This class should only be instantiated by calling LiveGenerativeModel.connect.

    Index

    Constructors

    Methods

    • Beta

      Closes this session. All methods on this session will throw an error once this resolves.

      Returns Promise<void>

    • Beta

      Resumes an existing live session with the server.

      This closes the current WebSocket connection and establishes a new one using the same configuration (URI, headers, model, system instruction, tools, etc.) as the original session.

      Parameters

      • OptionalsessionResumption: SessionResumptionConfig

        The configuration for session resumption, such as the handle to the previous session state to restore.

      Returns Promise<void>

      If the session resumption configuration is unsupported.

    • Beta

      Sends content to the server.

      Parameters

      • request: string | (string | Part)[]

        The message to send to the model.

      • turnComplete: boolean = true

        Indicates if the turn is complete. Defaults to false.

      Returns Promise<void>

      If this session has been closed.

    • Beta

      Sends audio data to the server in realtime.

      Parameters

      Returns Promise<void>

      The server requires that the audio data is base64-encoded 16-bit PCM at 16kHz little-endian.

      // const pcmData = ... base64-encoded 16-bit PCM at 16kHz little-endian.
      const blob = { mimeType: "audio/pcm", data: pcmData };
      liveSession.sendAudioRealtime(blob);

      If this session has been closed.

    • Beta

      Sends function responses to the server.

      Parameters

      Returns Promise<void>

      If this session has been closed.

    • Beta

      Sends realtime input to the server.

      Parameters

      Returns Promise<void>

      Use sendTextRealtime(), sendAudioRealtime(), and sendVideoRealtime() instead.

      If this session has been closed.

    • Beta

      Sends text to the server in realtime.

      Parameters

      • text: string

        The text data to send.

      Returns Promise<void>

      liveSession.sendTextRealtime("Hello, how are you?");
      

      If this session has been closed.

    • Beta

      Sends video data to the server in realtime.

      Parameters

      Returns Promise<void>

      The server requires that the video is sent as individual video frames at 1 FPS. It is recommended to set mimeType to image/jpeg.

      // const videoFrame = ... base64-encoded JPEG data
      const blob = { mimeType: "image/jpeg", data: videoFrame };
      liveSession.sendVideoRealtime(blob);

      If this session has been closed.

    Properties

    connectionPromise: Promise<void>

    Allows external code to await the opening of the WebSocket connection.

    inConversation: boolean = false

    Indicates whether this Live session is being controlled by an AudioConversationController.

    isClosed: boolean = false

    Indicates whether this Live session is closed.