Overview
Pipecat provides several utility modules for configuring transports and handling transport-specific operations. While the development runner handles most of these automatically, these utilities are useful for custom setups, advanced configurations, or when building your own deployment infrastructure.
Daily Configuration
The Daily utilities handle room creation, token generation, and authentication setup for Daily integration.
Basic Configuration
Use configure()
for simple room and token setup:
import aiohttp
from pipecat.runner.daily import configure
async with aiohttp.ClientSession() as session:
room_url, token = await configure(session)
# Use with DailyTransport
transport = DailyTransport(room_url, token, "Bot Name", params=DailyParams())
This function:
- Uses
DAILY_SAMPLE_ROOM_URL
environment variable if set, otherwise creates a new room
- Creates rooms with 2-hour expiration and automatic ejection
- Generates an authentication token with 2-hour expiration using
DAILY_API_KEY
- Returns a room URL and token ready for use
Environment Variables
Required:
DAILY_API_KEY
: Daily API key for creating rooms and tokens
Optional:
DAILY_SAMPLE_ROOM_URL
: Use an existing room instead of creating one
DAILY_API_URL
: Override Daily API endpoint (defaults to https://api.daily.co/v1)
Room and Token Management
When no DAILY_SAMPLE_ROOM_URL
is provided, rooms are created automatically with:
- 2-hour expiration from creation time
- Automatic participant ejection when the room expires
- Unique names using UUID prefixes (e.g.
pipecat-uuid
)
Expired rooms are automatically cleaned up by Daily, so you don’t need to
manage them manually.
Tokens are generated with 2-hour expiration and include necessary permissions for bot participation. The utilities handle all the Daily REST API interactions automatically.
LiveKit Configuration
LiveKit utilities manage authentication tokens, room setup, and agent permissions for LiveKit server integration.
Basic Configuration
Use configure()
for standard setup:
from pipecat.runner.livekit import configure
url, token, room_name = await configure()
# Use with LiveKitTransport
transport = LiveKitTransport(url=url, token=token, room_name=room_name, params=LiveKitParams())
Configuration with Arguments
For command-line integration:
import argparse
from pipecat.runner.livekit import configure_with_args
parser = argparse.ArgumentParser()
url, token, room_name, args = await configure_with_args(parser)
Supports these command-line options:
-r, --room
: Specify LiveKit room name
-u, --url
: Specify LiveKit server URL
Token Generation
LiveKit provides two token generation functions:
generate_token(room_name, participant_name, api_key, api_secret)
Creates a standard participant token for users or testing.
generate_token_with_agent(room_name, participant_name, api_key, api_secret)
Creates an agent token with special permissions. Use this for your bots.
from pipecat.runner.livekit import generate_token_with_agent
# Generate agent token for your bot
agent_token = generate_token_with_agent("my-room", "Pipecat Bot", api_key, api_secret)
# Generate user token for testing
user_token = generate_token("my-room", "Test User", api_key, api_secret)
Environment Variables
Required:
LIVEKIT_API_KEY
: LiveKit API key
LIVEKIT_API_SECRET
: LiveKit API secret
LIVEKIT_URL
: LiveKit server URL
LIVEKIT_ROOM_NAME
: Default room name
All environment variables are required for LiveKit to function properly.
WebSocket and Transport Utilities
The transport utilities provide helper functions for WebSocket parsing, SDP manipulation, and transport management.
Telephony WebSocket Parsing
Use parse_telephony_websocket()
to auto-detect telephony providers and extract call data:
from pipecat.runner.utils import parse_telephony_websocket
transport_type, call_data = await parse_telephony_websocket(websocket)
if transport_type == "twilio":
stream_id = call_data["stream_id"]
call_id = call_data["call_id"]
elif transport_type == "telnyx":
stream_id = call_data["stream_id"]
call_control_id = call_data["call_control_id"]
outbound_encoding = call_data["outbound_encoding"]
elif transport_type == "plivo":
stream_id = call_data["stream_id"]
call_id = call_data["call_id"]
The function automatically:
- Reads and parses initial WebSocket messages
- Detects provider based on message structure
- Extracts provider-specific call information
- Returns structured data for transport configuration
Transport Helper Functions
Client ID Detection:
from pipecat.runner.utils import get_transport_client_id
client_id = get_transport_client_id(transport, client)
# Returns pc_id for WebRTC or participant ID for Daily
Video Capture (Daily only):
from pipecat.runner.utils import maybe_capture_participant_camera, maybe_capture_participant_screen
# Capture participant's camera
await maybe_capture_participant_camera(transport, client, framerate=30)
# Capture participant's screen
await maybe_capture_participant_screen(transport, client, framerate=15)
These functions safely handle transport detection and only execute if the transport supports the operation.
When to Use These Utilities
Automatic Usage (Most Common)
The development runner and create_transport
utility handle these automatically. Most users won’t need to call these functions directly.
Manual Usage (Advanced)
Use these utilities directly when:
Custom deployment infrastructure: Building your own bot runner or deployment system
Advanced transport configuration: Need specific room settings, token permissions, or custom authentication
Non-runner scenarios: Integrating Pipecat transports into existing applications
Testing and debugging: Need to create rooms/tokens independently for testing
Integration Example
Here’s how you might use these utilities in a custom deployment:
import aiohttp
from pipecat.runner.daily import configure
from pipecat.runner.utils import parse_telephony_websocket
from pipecat.transports.services.daily import DailyTransport, DailyParams
async def create_custom_bot_session(transport_type: str):
if transport_type == "daily":
async with aiohttp.ClientSession() as session:
room_url, token = await configure(session)
return DailyTransport(room_url, token, "Custom Bot", DailyParams())
elif transport_type == "telephony":
# Handle custom telephony setup
transport_type, call_data = await parse_telephony_websocket(websocket)
# Configure based on detected provider...
These utilities provide the building blocks for any transport configuration scenario while maintaining the same reliability and functionality as the development runner.