Skip to main content
The Gemini Live Websocket transport implementation enables real-time audio communication with the Gemini Live service, using a direct websocket connection.
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, to securely handle API keys.

Installation

Add the transport dependency to your app/build.gradle.kts:
dependencies {
    implementation("ai.pipecat:gemini-live-websocket-transport:0.3.7")
}
Add the microphone permission to AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />

Usage

import ai.pipecat.client.RTVIClient
import ai.pipecat.client.RTVIEventCallbacks
import ai.pipecat.client.gemini_live_websocket.GeminiLiveWebsocketTransport
import ai.pipecat.client.types.BotReadyData
import ai.pipecat.client.types.RTVIClientOptions
import ai.pipecat.client.types.RTVIClientParams
import ai.pipecat.client.types.Value

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

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

val transport = GeminiLiveWebsocketTransport.Factory(context)

val options = RTVIClientOptions(
    params = RTVIClientParams(
        baseUrl = null,
        config = GeminiLiveWebsocketTransport.buildConfig(
            apiKey = "your-gemini-api-key",
            model = "models/gemini-2.0-flash-exp",
            generationConfig = Value.Object(
                "speech_config" to Value.Object(
                    "voice_config" to Value.Object(
                        "prebuilt_voice_config" to Value.Object(
                            "voice_name" to Value.Str("Puck")
                        )
                    )
                )
            ),
            initialUserMessage = "How tall is the Eiffel Tower?"
        )
    )
)

val client = RTVIClient(transport, callbacks, options)

client.connect().withCallback { result ->
    result.errorOrNull?.let { Log.e(TAG, "Connection failed: $it") }
}

Configuration

buildConfig

GeminiLiveWebsocketTransport.buildConfig() accepts the following parameters:
ParameterTypeDescription
apiKeyStringYour Gemini API key
modelStringModel name (default: "models/gemini-2.0-flash-exp")
initialUserMessageString?Optional message to send at session start
generationConfigValue.ObjectGeneration config (voice, language, etc.)
systemInstructionValue?Optional system instruction
toolsValue.ArrayOptional tools/function definitions

Audio devices

The transport exposes static constants for audio routing:
// Route audio to speakerphone (default) or earpiece
client.updateMic(GeminiLiveWebsocketTransport.AudioDevices.Speakerphone.id)
client.updateMic(GeminiLiveWebsocketTransport.AudioDevices.Earpiece.id)

Resources

Demo

Simple Chatbot Demo

Source

Client Transports

Pipecat Android Client Reference

Complete API documentation for the Pipecat Android client.