livekit

LiveKit room and token configuration utilities.

This module provides helper functions for creating and configuring LiveKit rooms and authentication tokens. It handles JWT token generation with appropriate grants for both regular participants and AI agents.

The module supports creating tokens for development and testing, with automatic agent detection for proper room permissions.

Required environment variables:

  • LIVEKIT_API_KEY - LiveKit API key

  • LIVEKIT_API_SECRET - LiveKit API secret

  • LIVEKIT_URL - LiveKit server URL

  • LIVEKIT_ROOM_NAME - Room name to join

Example:

from pipecat.runner.livekit import configure

url, token, room_name = await configure()
# Use with LiveKitTransport
pipecat.runner.livekit.generate_token(room_name: str, participant_name: str, api_key: str, api_secret: str) str[source]

Generate a LiveKit access token for a participant.

Parameters:
  • room_name – Name of the LiveKit room.

  • participant_name – Name of the participant.

  • api_key – LiveKit API key.

  • api_secret – LiveKit API secret.

Returns:

JWT token string for room access.

pipecat.runner.livekit.generate_token_with_agent(room_name: str, participant_name: str, api_key: str, api_secret: str) str[source]

Generate a LiveKit access token for an agent participant.

Parameters:
  • room_name – Name of the LiveKit room.

  • participant_name – Name of the participant.

  • api_key – LiveKit API key.

  • api_secret – LiveKit API secret.

Returns:

JWT token string for agent room access.

async pipecat.runner.livekit.configure()[source]

Configure LiveKit room URL and token from arguments or environment.

Returns:

Tuple containing the server URL, authentication token, and room name.

Raises:

Exception – If required LiveKit configuration is not provided.

async pipecat.runner.livekit.configure_with_args(parser: ArgumentParser | None = None)[source]

Configure LiveKit room with command-line argument parsing.

Parameters:

parser – Optional argument parser. If None, creates a default one.

Returns:

Tuple containing server URL, authentication token, room name, and parsed arguments.

Raises:

Exception – If required LiveKit configuration is not provided via arguments or environment.