hi from a quickstart code i have added functionali...
# ask-ai
r
hi from a quickstart code i have added functionality of avavatar can i also add egress there but i dont see any config set up on my livekit cloud page for that ?
t
Thanks for reaching out, Areeb. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — thanks for the question. You can add egress to your quickstart that already has avatar functionality. Avatars and egress are independent: avatars handle the visual/agent output, while egress handles recording or streaming room content externally. A few quick points to clarify why you don’t see an “egress” config on the cloud page and how to proceed: • There isn’t a dedicated egress settings page in the LiveKit Cloud UI. Egress is normally started programmatically (via the Server SDK or CLI), and you’ll see active/completed egress sessions after they run. • Common ways to start egress: ◦ Start a room- or track-composite egress from your backend using the LiveKit Server SDK (Go, Node, Python, etc.) by calling the StartRoomCompositeEgress / StartTrackCompositeEgress / StartTrackEgress endpoints. ◦ Use the LiveKit CLI to test egress without changing your code. • Supported outputs include files (MP4/WebM), RTMP, and HLS. You typically provide output details (e.g., S3, RTMP URL) when you call the egress API. • Use webhooks (Settings → Webhooks) to receive notifications when egress starts/finishes so you can monitor jobs. If you want, I can give you exact example code and steps. To tailor that, please tell me: 1. Which Server SDK or language are you using (Go, Node, Python, etc.)? 2. Do you want file recordings (S3/MP4), RTMP streaming, or HLS? 3. Do you already have backend credentials set up (
LIVEKIT_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 | LiveKit
r
currently i have this : from dotenv import load_dotenv from livekit import agents, rtc from livekit.agents import AgentServer, AgentSession, Agent, room_io # --- IMPORT ANAM --- from livekit.plugins import anam, noise_cancellation, silero from livekit.plugins.turn_detector.multilingual import MultilingualModel load_dotenv(".env.local") class Assistant(Agent): def __init__(self) -> None: super().__init__( instructions=""" You are a helpful voice AI assistant. Responses are concise and friendly. Do not use emojis or asterisks. """ ) server = AgentServer() @breezy-insurance-66772.rtc_session() async def entrypoint(ctx: agents.JobContext): # 1. Load VAD (Synchronous) vad = silero.VAD.load() session = AgentSession( stt="assemblyai/universal-streaming:en", llm="openai/gpt-4.1-mini", tts="cartesia/sonic-3:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc", vad=vad, turn_detection=MultilingualModel(), ) # --- 2. CONFIGURE & START AVATAR --- # We use the ID for "Cara" (Female Avatar) # Ensure ANAM_API_KEY is in your .env.local file avatar = anam.AvatarSession( persona_config=anam.PersonaConfig( name="Astrid", avatarId="bdaaedfa-00f2-417a-8239-8bb89adec682", ) ) # Start the avatar session first await avatar.start(session, room=ctx.room) # --- 3. START AGENT SESSION --- await session.start( room=ctx.room, agent=Assistant(), room_options=room_io.RoomOptions( # CRITICAL: Disable default audio output so we don't hear echo # (The audio will come from the Avatar video stream instead) audio_output=False, audio_input=room_io.AudioInputOptions( noise_cancellation=lambda _: noise_cancellation.BVC(), ), ), ) # 4. Greet and finish await session.generate_reply( instructions="Greet the user and ask how you can help." ) if name == "__main__": agents.cli.run_app(server) now how to add egress ? can i use my local storage to store it ?
t
Thanks — this is helpful. You can add egress to your existing Python quickstart that starts an avatar + agent. Egress is started from your backend (server-side) and can write to local disk, S3, or stream to RTMP/HLS. I’ll show a minimal, focused example that starts a room composite egress to an MP4 file on local storage and point out important considerations. Before you add code, please confirm: 1. Are you running the AgentServer on a machine with persistent disk access (not an ephemeral container)? 2. Which output format do you want (MP4 is common)? 3. Do you want to record the whole room composite (all participant audio/video + avatar) or a single track? If those look fine, here’s how to hook egress in with your existing flow. The example uses the LiveKit Server SDK pattern for starting a Room Composite egress from Python (invoke from your backend once the room/session is running). 1) Ensure server-side credentials and client • Have these env vars set on the machine running egress: ◦
LIVEKIT_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).
Copy code
# 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).