LiveKit Protocol Stubs

1.1.5 · active · verified Fri Apr 10

livekit-protocol provides Python protocol stubs for LiveKit, a powerful open-source platform for real-time video, audio, and data communication. It contains the protobuf message definitions used internally by other LiveKit Python SDK components like livekit-client and livekit-rtc. The library is actively maintained as part of the LiveKit Python SDKs monorepo, with frequent updates that often align with new features across the LiveKit ecosystem. The current version is 1.1.5.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and instantiate a basic protobuf message, `ParticipantInfo`, from the `livekit-protocol` library. This library is primarily for defining the structure of messages used in LiveKit's real-time communication, and direct interaction is typically for advanced use cases or internal SDK development.

from livekit.protocol import livekit_models as models

# Create a ParticipantInfo message
participant_info = models.ParticipantInfo(
    sid="PA_12345",
    identity="test-user",
    name="Test User",
    state=models.ParticipantInfo.State.JOINED,
    metadata="{}"
)

print(f"Participant SID: {participant_info.sid}")
print(f"Participant Identity: {participant_info.identity}")
print(f"Participant State: {participant_info.state}")

# You can also serialize/deserialize these messages
serialized_data = participant_info.SerializeToString()

# To deserialize (e.g., from a network stream)
new_participant_info = models.ParticipantInfo()
new_participant_info.ParseFromString(serialized_data)

print(f"Deserialized Participant Identity: {new_participant_info.identity}")

view raw JSON →