rough-wolf-70047
02/25/2026, 4:10 PMtall-airline-16756
02/25/2026, 4:10 PMtall-airline-16756
02/25/2026, 4:11 PMLIVEKIT_API_KEY, LIVEKIT_API_SECRET, LIVEKIT_URL)?
Share those details and I’ll provide a focused example and the minimal changes to add egress to your quickstart.
Sources: Universal Egress | Best practices for managing webhook event streams | LiveKit | Backup Egress Recordings | Support data sovereignty in India | LiveKitrough-wolf-70047
02/26/2026, 8:21 AMtall-airline-16756
02/26/2026, 8:21 AMLIVEKIT_API_KEY
◦ LIVEKIT_API_SECRET
◦ LIVEKIT_URL (your LiveKit Cloud URL)
• Run egress from your backend — not from the browser client.
2) Example: start a Room Composite egress to a local MP4 file
• Call this once your avatar + agent session is started and the room has content to record.
• Place this in your server code (the same process that runs AgentServer is fine if it has disk access).
# Example: start a room composite egress (pseudo-code / adapted)
from livekit import EgressClient, RoomCompositeEgressRequest, EncodedFileOutput, EncodedFileType
# create Egress client using LIVEKIT_URL, API key/secret
egress_client = EgressClient(url=os.environ["LIVEKIT_URL"],
api_key=os.environ["LIVEKIT_API_KEY"],
api_secret=os.environ["LIVEKIT_API_SECRET"])
async def start_room_recording(room_name: str, out_path: str = "/tmp/recording.mp4"):
# Build the request for a composite MP4 file
req = RoomCompositeEgressRequest(
room_name=room_name,
layout="speaker-dark", # or other layout / custom
output=RoomCompositeEgressRequest.File(
File=EncodedFileOutput(
file_type=EncodedFileType.MP4,
filepath=out_path
)
)
)
info = await egress_client.start_room_composite_egress(req)
return info # contains egress ID and metadata
Notes:
• Replace the client and request classes with exact names for your installed LiveKit Python server/egress SDK version; the code above shows the core fields you must provide: room_name, layout, and output.filepath.
• Local files: the egress process must have write permission to the path you specify. Use an absolute path on the host machine (e.g., /var/recordings/room1.mp4).
• If you run AgentServer in a container, ensure you mount a host directory into the container so files persist outside the container lifecycle.
• Filenames: use unique names (include room name + timestamp + egress id) to avoid collisions.
3) Monitoring and webhooks
• After you start egress, you’ll get an egress job ID. Use that to poll job status or configure webhooks (Settings → Webhooks) to receive start/finish events so you can move/process the file after completion.
4) If you prefer streaming outputs
• RTMP: supply an RTMP URL in the request to stream live to a streaming provider.
• S3/HLS: you can output directly to S3 (requires S3 credentials or assume-role setup) or HLS segments.
5) Integrating into your existing flow
• A practical spot to start egress is right after you start the avatar and session and after you call await session.generate_reply(...) for the greeting — or whenever you want recording to begin.
• Example location:
◦ After await avatar.start(session, room=ctx.room) and await session.start(...), call await start_room_recording(ctx.room).
If you want, I can:
• Provide a fully runnable Python snippet matching the exact LiveKit Python SDK you have installed (tell me the package/version).
• Give an example that records a single track instead of the whole room.
• Show how to mount a host folder into Docker to persist the mp4 file.
Which of the above would you like next? And confirm whether you have persistent local storage available (host path or container mount).