{"id":2572,"library":"livekit-protocol","title":"LiveKit Protocol Stubs","description":"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.","status":"active","version":"1.1.5","language":"en","source_language":"en","source_url":"https://github.com/livekit/python-sdks/","tags":["livekit","rtc","protocol","protobuf","webrtc","realtime"],"install":[{"cmd":"pip install livekit-protocol","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"ParticipantInfo","correct":"from livekit.protocol import livekit_models as models\n# then use models.ParticipantInfo(...)"},{"symbol":"JoinResponse","correct":"from livekit.protocol import livekit_rtc as rtc\n# then use rtc.JoinResponse(...)"}],"quickstart":{"code":"from livekit.protocol import livekit_models as models\n\n# Create a ParticipantInfo message\nparticipant_info = models.ParticipantInfo(\n    sid=\"PA_12345\",\n    identity=\"test-user\",\n    name=\"Test User\",\n    state=models.ParticipantInfo.State.JOINED,\n    metadata=\"{}\"\n)\n\nprint(f\"Participant SID: {participant_info.sid}\")\nprint(f\"Participant Identity: {participant_info.identity}\")\nprint(f\"Participant State: {participant_info.state}\")\n\n# You can also serialize/deserialize these messages\nserialized_data = participant_info.SerializeToString()\n\n# To deserialize (e.g., from a network stream)\nnew_participant_info = models.ParticipantInfo()\nnew_participant_info.ParseFromString(serialized_data)\n\nprint(f\"Deserialized Participant Identity: {new_participant_info.identity}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Unless you specifically need to handle raw LiveKit protocol messages (e.g., implementing a custom signalling server or proxy), prefer using `livekit-client` or `livekit-rtc`.","message":"The `livekit-protocol` library is a low-level dependency. Most application developers should interact with LiveKit using higher-level libraries like `livekit-client` (for web/mobile client-like functionality) or `livekit-rtc` (for server-side room control) which abstract away the direct manipulation of these protocol messages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always ensure that `livekit-protocol` is kept in sync with the major and minor versions of other `livekit-client` or `livekit-rtc` libraries you are using. Refer to the LiveKit Python SDK changelogs for specific details on protocol changes before upgrading.","message":"Protocol definitions can change between minor versions of `livekit-protocol`, especially when new features or data structures (e.g., new event types, added fields to existing messages) are introduced. Mismatched versions with other `livekit-*` libraries in your project can lead to serialization/deserialization errors or unexpected behavior.","severity":"breaking","affected_versions":"All versions, particularly when upgrading minor versions across the LiveKit SDKs."},{"fix":"When looking for a specific message, consult the `livekit/protocol` directory in the source code to identify which `livekit_*.py` module it resides in, and import accordingly (e.g., `from livekit.protocol import livekit_models as models`).","message":"This library contains generated code from `.proto` files. While the imports typically follow `from livekit.protocol import livekit_models`, the module names correspond directly to the original `.proto` file names (e.g., `livekit_models.proto` becomes `livekit_models.py`). Be mindful of this convention when importing specific message types.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}