Skip to main content
The Small WebRTC transport enables real-time audio communication with a Pipecat bot over a direct WebRTC connection, with no third-party account required.

Installation

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

Usage

import ai.pipecat.client.PipecatClientOptions
import ai.pipecat.client.PipecatEventCallbacks
import ai.pipecat.client.small_webrtc_transport.PipecatClientSmallWebRTC
import ai.pipecat.client.small_webrtc_transport.SmallWebRTCTransport
import ai.pipecat.client.types.APIRequest
import ai.pipecat.client.types.BotReadyData
import ai.pipecat.client.types.Value

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 = PipecatClientSmallWebRTC(SmallWebRTCTransport(context), options)

// Connect via your server endpoint (recommended)
client.startBotAndConnect(
    APIRequest(endpoint = "https://your-server.com/api/offer", requestData = Value.Object())
).withCallback { result ->
    result.errorOrNull?.let { Log.e(TAG, "Connection failed: $it") }
}

// Or connect with coroutines
// client.startBotAndConnect(...).await()

Configuration

IceConfig

Pass custom ICE servers for TURN/STUN support:
val iceConfig = IceConfig(
    iceServers = listOf(
        IceServer(
            urls = listOf("turn:your-turn-server.com:3478"),
            username = "user",
            credential = "pass"
        )
    )
)

val transport = SmallWebRTCTransport(context, iceConfig = iceConfig)

Audio devices

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

Camera selection

// Switch between front and rear cameras
client.updateCam(SmallWebRTCTransport.Cameras.Front.id)
client.updateCam(SmallWebRTCTransport.Cameras.Rear.id)

Resources

Demo

Demo App

Source

Client Transports

Pipecat Android Client Reference

Complete API documentation for the Pipecat Android client.