> ## Documentation Index
> Fetch the complete documentation index at: https://daily-ms-ws-body-url-encode.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Live WebSocket Transport

> The Gemini Live WebSocket transport for the Pipecat Android SDK: connect Kotlin apps directly to Google's Gemini Live service.

The Gemini Live Websocket transport implementation enables real-time audio communication with the Gemini Live service, using a direct websocket connection.

<Note>
  Transports of this type are designed primarily for development and testing
  purposes. For production applications, you will need to build a server
  component with a server-friendly transport, like the
  [DailyTransport](./daily), to securely handle API keys.
</Note>

## Installation

Add the transport dependency to your `app/build.gradle.kts`:

```kotlin theme={null}
dependencies {
    implementation("ai.pipecat:gemini-live-websocket-transport:1.2.0")
}
```

Add the microphone permission to `AndroidManifest.xml`:

```xml theme={null}
<uses-permission android:name="android.permission.RECORD_AUDIO" />
```

## Usage

```kotlin theme={null}
import ai.pipecat.client.PipecatClientOptions
import ai.pipecat.client.PipecatEventCallbacks
import ai.pipecat.client.gemini_live_websocket.GeminiLiveWebsocketTransport
import ai.pipecat.client.gemini_live_websocket.GeminiServiceOptions
import ai.pipecat.client.gemini_live_websocket.PipecatClientGeminiLiveWebsocket
import ai.pipecat.client.types.BotReadyData

val callbacks = object : PipecatEventCallbacks() {
    override fun onBackendError(message: String) {
        Log.e(TAG, "Backend error: $message")
    }

    override fun onBotReady(data: BotReadyData) {
        Log.d(TAG, "Bot is ready")
    }
}

val options = PipecatClientOptions(callbacks = callbacks, enableMic = true)
val client = PipecatClientGeminiLiveWebsocket(GeminiLiveWebsocketTransport(context), options)

client.connect(
    GeminiServiceOptions.withDefaults(
        apiKey = "your-gemini-api-key",
        voice = "Puck",
        initialUserMessage = "How tall is the Eiffel Tower?"
    )
).withCallback { result ->
    result.errorOrNull?.let { Log.e(TAG, "Connection failed: $it") }
}
```

## Configuration

### GeminiServiceOptions

`connect()` takes a `GeminiServiceOptions`:

| Parameter | Type | Description |
| - | - | - |
| `apiKey` | `String` | Your Gemini API key |
| `modelConfig` | `Value` | Model setup for the Live API (model name, generation config, system instruction, tools) |
| `initialUserMessage` | `String?` | Optional message to send at session start |

### GeminiServiceOptions.withDefaults

For common cases, `GeminiServiceOptions.withDefaults()` builds the `modelConfig` for you (audio output with the given voice):

| Parameter | Type | Description |
| - | - | - |
| `apiKey` | `String` | Your Gemini API key |
| `model` | `String` | Model name (default: `"models/gemini-3.1-flash-live-preview"`) |
| `initialUserMessage` | `String?` | Optional message to send at session start |
| `voice` | `String` | Voice name (default: `"Puck"`) |
| `systemInstruction` | `Value?` | Optional system instruction |
| `tools` | `Value.Array` | Optional tools/function definitions |

### Audio devices

The transport exposes static constants for audio routing:

```kotlin theme={null}
// Route audio to speakerphone (default) or earpiece
client.updateMic(GeminiLiveWebsocketTransport.AudioDevices.Speakerphone.id)
client.updateMic(GeminiLiveWebsocketTransport.AudioDevices.Earpiece.id)
```

## Resources

<CardGroup cols={2}>
  <Card horizontal title="Demo" icon="play" href="https://github.com/pipecat-ai/pipecat-client-android-gemini-live-websocket-demo">
    Simple Chatbot Demo
  </Card>

  <Card horizontal title="Source" icon="github" href="https://github.com/pipecat-ai/pipecat-client-android-transports/">
    Client Transports
  </Card>
</CardGroup>

<Card title="Pipecat Android Client Reference" icon="book-open" href="https://docs-android.rtvi.ai/">
  Complete API documentation for the Pipecat Android client.
</Card>
