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()