Overview
LiveKitTransport
provides real-time audio communication capabilities using LiveKit’s open-source WebRTC platform. It supports bidirectional audio streaming, data messaging, participant management, and room event handling for conversational AI applications with the flexibility of self-hosted or cloud infrastructure.
LiveKitTransport API
Transport methods and configuration options
LiveKit Docs
Official LiveKit API documentation
Example Code
Working example with voice agent implementation
LiveKit Cloud
Sign up for hosted LiveKit service
Installation
To use LiveKitTransport, install the required dependencies:Get started quickly with LiveKit Cloud or
self-host LiveKit
for full control.
Frames
Input
UserAudioRawFrame
- Audio data from room participantsLiveKitTransportMessageUrgentFrame
- Data messages from participants
Output
OutputAudioRawFrame
- Audio data to room participantsLiveKitTransportMessageFrame
- Data messages to participantsLiveKitTransportMessageUrgentFrame
- Urgent messages to participants
Key Features
- Open Source Platform: Self-hosted or cloud options with full control over infrastructure
- Data Messaging: Bidirectional data channels for application messaging
- Participant Management: Built-in participant controls and metadata management
- Scalable Architecture: Handles multiple concurrent rooms and participants
Usage Example
Room Creation
LiveKit requires a url, room, and corresponding token for authentication. Pipecat’s development runner provides a helper function to create room URL, token, and room name:Methods
LiveKitTransport
provides methods for room and participant management:
Room Management
get_participants()
- Get list of participant IDs in the roomsend_message()
- Send messages to participantssend_message_urgent()
- Send urgent messages to participants
Audio Control
send_audio()
- Send audio frames to the room
Participant Management
get_participant_metadata()
- Get metadata for specific participantsset_metadata()
- Set metadata for the local participantmute_participant()
- Mute a participant’s audio tracksunmute_participant()
- Unmute a participant’s audio tracks
For complete method signatures, parameters, and examples, see the
LiveKitTransport
API
reference.Example Usage
Event Handling
LiveKitTransport
provides event callbacks for room and participant management. Register callbacks using the @transport.event_handler()
decorator:
Connection Events
on_connected
- Connected to the LiveKit roomon_disconnected
- Disconnected from the LiveKit room
Participant Events
on_first_participant_joined
- First participant joins (useful for starting conversations)on_participant_connected
- Any participant joins the roomon_participant_disconnected
- Participant leaves the roomon_participant_left
- Participant left (alias for compatibility)
Audio Events
on_audio_track_subscribed
- Audio track from participant is availableon_audio_track_unsubscribed
- Audio track is no longer available
Communication Events
on_data_received
- Data messages received from participants
For complete event details, parameters, and examples, see the
LiveKitTransport
API
reference.Example Usage
Additional Notes
- Deployment Flexibility: Choose between LiveKit Cloud, self-hosted, or hybrid deployments
- Open Source: Full access to LiveKit server source code for customization
- Scalability: Horizontal scaling with multiple LiveKit servers
- Security: End-to-end encryption and configurable authentication
- Platform Support: Native SDKs for web, iOS, Android, and server applications