# Class GeminiLlmConnection

java.lang.Object
com.google.adk.models.GeminiLlmConnection

All Implemented Interfaces:
  `BaseLlmConnection`

public final class GeminiLlmConnection extends Object implements BaseLlmConnection
Manages a persistent, bidirectional connection to the Gemini model via WebSockets for real-time interaction.

This connection allows sending conversation history, individual messages, function responses, and real-time media blobs (like audio chunks) while continuously receiving responses from the model.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the connection.
  `void`
  `close(Throwable throwable)`
  Closes the connection with an error.
  `io.reactivex.rxjava3.core.Flowable<LlmResponse>`
  `receive()`
  Receives the model responses.
  `io.reactivex.rxjava3.core.Completable`
  `sendContent(com.google.genai.types.Content content)`
  Sends a user content to the model.
  `io.reactivex.rxjava3.core.Completable`
  `sendHistory(List<com.google.genai.types.Content> history)`
  Sends the conversation history to the model.
  `io.reactivex.rxjava3.core.Completable`
  `sendRealtime(com.google.genai.types.Blob blob)`
  Sends a chunk of audio or a frame of video to the model in realtime.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### sendHistory

    public io.reactivex.rxjava3.core.Completable sendHistory(List<com.google.genai.types.Content> history)
    Description copied from interface: `BaseLlmConnection`
    Sends the conversation history to the model.

    You call this method right after setting up the model connection. The model will respond if the last content is from user, otherwise it will wait for new user input before responding.

    Specified by:
      `sendHistory` in interface `BaseLlmConnection`

  - ### sendContent

    public io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content)
    Description copied from interface: `BaseLlmConnection`
    Sends a user content to the model.

    The model will respond immediately upon receiving the content. If you send function responses, all parts in the content should be function responses.

    Specified by:
      `sendContent` in interface `BaseLlmConnection`

  - ### sendRealtime

    public io.reactivex.rxjava3.core.Completable sendRealtime(com.google.genai.types.Blob blob)
    Description copied from interface: `BaseLlmConnection`
    Sends a chunk of audio or a frame of video to the model in realtime.

    The model may not respond immediately upon receiving the blob. It will do voice activity detection and decide when to respond.

    Specified by:
      `sendRealtime` in interface `BaseLlmConnection`

  - ### receive

    public io.reactivex.rxjava3.core.Flowable<LlmResponse> receive()
    Description copied from interface: `BaseLlmConnection`
    Receives the model responses.
    Specified by:
      `receive` in interface `BaseLlmConnection`

  - ### close

    public void close()
    Description copied from interface: `BaseLlmConnection`
    Closes the connection.
    Specified by:
      `close` in interface `BaseLlmConnection`

  - ### close

    public void close(Throwable throwable)
    Description copied from interface: `BaseLlmConnection`
    Closes the connection with an error.
    Specified by:
      `close` in interface `BaseLlmConnection`