This is a starter template for LiveKit Agents that provides a simple voice interface using the LiveKit Swift SDK. It supports voice, transcriptions, and virtual avatars.
This template is compatible with iOS, iPadOS, macOS, and visionOS and is free for you to use or modify as you see fit.
The easiest way to get this app running is with the Sandbox for LiveKit Cloud and the LiveKit CLI.
First, create a new Sandbox Token Server for your LiveKit Cloud project.
Then, run the following command to automatically clone this template and connect it to LiveKit Cloud.
lk app create --template voice-assistant-swift --sandbox <token_server_sandbox_id>
Built and run the app from Xcode by opening VoiceAssistant.xcodeproj
. You may need to adjust your app signing settings to run the app on your device.
You'll also need an agent to speak with. Try our voice AI quickstart for the easiest way to get started.
Note
To setup without the LiveKit CLI, clone the repository and then either create a VoiceAssistant/.env.xcconfig
with a LIVEKIT_SANDBOX_ID
(if using a Sandbox Token Server), or open TokenService.swift
and add your manually generated URL and token.
In a production environment, you will be responsible for developing a solution to generate tokens for your users which is integrated with your authentication solution. You should disable your sandbox token server and modify TokenService.swift
to use your own token server.
The app supports agent transcriptions. It requires some client-side processing to aggregate the partial results into messages. TranscriptionStreamReceiver
is responsible for this aggregation. It buffers stream chunks and publishes complete messages when the transcription is finished. Messages have unique IDs and timestamps to help with ordering and display in the UI.
Note
Text streams are fully supported in LiveKit Agents v1, for v0.x, you'll need to use legacy transcription events as shown in TranscriptionDelegateReceiver.swift
.
This template is open source and we welcome contributions! Please open a PR or issue through GitHub, and don't forget to join us in the LiveKit Community Slack!