echoing-lamp-18687
11/27/2025, 12:19 PMtall-airline-16756
11/27/2025, 12:19 PMtall-airline-16756
11/27/2025, 12:19 PMegress field (room_config.egress).
• If you mean on‑demand recording: use the Egress API (Room Composite, Participant, Track Composite, or Track egress) via Server SDKs, the LiveKit CLI, or direct calls to the /twirp/livekit.Egress/ endpoints.
If you tell me which method you want (auto vs on‑demand), which SDK or tool you’re using (Go/JS/Python/CLI/curl), and whether you’re recording to S3/HLS/file, I’ll give the exact config or example request.
Sources: Auto egress | LiveKit docs | Recording and export | LiveKit docs | Egress API | LiveKit docs | How to enable auto-egress with SIPechoing-lamp-18687
11/27/2025, 12:23 PMechoing-lamp-18687
11/27/2025, 12:23 PMtall-airline-16756
11/27/2025, 12:24 PMroomRecord permission when starting recordings.
• You can enable auto‑egress in CreateRoom by setting the egress field, or start on‑demand egress via the Egress API (Room Composite, Participant, Track, or Web egress) using Server SDKs, CLI, or direct API calls.
Tell me whether you want auto‑egress or on‑demand, which SDK/tool you’ll use (Cloud console/Go/JS/Python/CLI/curl), and your target output (S3/HLS/file) and I’ll provide the exact config or request example.echoing-lamp-18687
11/27/2025, 12:24 PMtall-airline-16756
11/27/2025, 12:25 PMechoing-lamp-18687
11/27/2025, 12:25 PMtall-airline-16756
11/27/2025, 12:26 PMdocker run -d \
--cap-add=SYS_ADMIN \
-e EGRESS_CONFIG_BODY='{
"api_key":"YOUR_LIVEKIT_API_KEY",
"api_secret":"YOUR_LIVEKIT_API_SECRET",
"ws_url":"ws://YOUR_LIVEKIT_HOST:7880",
"redis": {"address":"YOUR_REDIS_HOST:6379"}
}' \
livekit/egress
• Notes: --cap-add=SYS_ADMIN is needed for Chrome sandboxing. Egress must connect to the same Redis instance as LiveKit. Minimum recommended resources: ~4 CPU / 4 GB RAM.
2) Ensure permissions & AWS setup
• LiveKit API key must have roomRecord permission.
• Create an S3 bucket and IAM credentials with PutObject/List permissions.
• Set environment vars on the machine running your Python code (or Egress if using S3 from egress):
LIVEKIT_API_KEY=...
LIVEKIT_API_SECRET=...
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=...
AWS_BUCKET_NAME=...
3) Install Python SDK
pip install livekit-api
4) Start automatic recording (recommended flow)
• The Python SDK does not implicitly auto‑start egress on CreateRoom in some setups, so trigger egress immediately after room creation (or when the first participant joins).
• Example: create room then start Room Composite egress to S3.
Synchronous-style example (async shown where required):
import asyncio
import os
from livekit import api
async def start_room_recording(room_name: str):
lk = api.LiveKitAPI(
url="http://YOUR_LIVEKIT_HOST:7880",
api_key=os.getenv("LIVEKIT_API_KEY"),
api_secret=os.getenv("LIVEKIT_API_SECRET"),
)
req = api.RoomCompositeEgressRequest(
room_name=room_name,
file_outputs=[
api.EncodedFileOutput(
filepath=f"recordings/{room_name}-{int(__import__('time').time())}.mp4",
file_type=api.EncodedFileType.MP4,
s3=api.S3Upload(
bucket=os.getenv("AWS_BUCKET_NAME"),
region=os.getenv("AWS_REGION"),
access_key=os.getenv("AWS_ACCESS_KEY_ID"),
secret=os.getenv("AWS_SECRET_ACCESS_KEY"),
),
)
],
layout="grid"
)
egress_info = await lk.egress.start_room_composite_egress(req)
print("Started egress:", egress_info.egress_id)
await lk.aclose()
# Usage: call this after creating the room or when first participant joins
if __name__ == "__main__":
asyncio.run(start_room_recording("my-auto-room"))
5) Automate triggering
• Trigger the recording script after room creation:
◦ Call it from the same service that creates rooms, or
◦ Run a background worker that starts recording when a room appears or when first participant joins.
• You can also periodically call ListEgress to monitor status and StopEgress to stop.
6) Verify & troubleshoot
• Verify Egress service logs and that it connects to Redis and LiveKit.
• Check ListEgress to view status.
• If Chrome fails to start in egress: ensure --cap-add=SYS_ADMIN.
• If S3 upload fails: check AWS creds, region, bucket policy, and that Egress or your Python process can reach S3.
If you want, I can:
• Provide a Docker Compose example including LiveKit + Egress + Redis + example worker, or
• Give a ready-to-run Python webhook/worker that creates the room and immediately starts recording. Which would you prefer? Sources: Recording and export | LiveKit docs | Auto egress | LiveKit docs | Egress output types | LiveKit docs | RoomComposite Egress | LiveKit Docs | Self-hosting the Egress Service | LiveKit docsechoing-lamp-18687
11/27/2025, 12:28 PMtall-airline-16756
11/27/2025, 12:28 PMroom_config.egress).
• With a self‑hosted setup, ensure the Egress service is deployed and connected to the same Redis/LiveKit instance so it can record the SIP-backed room.
• Recordings can be output to S3 the same way (Room Composite, Track, or Participant egress) using your Python code or by auto‑starting egress from the SIP dispatch rule.
If you want, tell me how your SIP is currently configured (do you create a LiveKit room from the SIP dispatch, or do calls join an existing room?), and I’ll give the exact SIP dispatch example and Python/S3 config.echoing-lamp-18687
11/27/2025, 12:29 PMtall-airline-16756
11/27/2025, 12:29 PM{
"name": "Record-Inbound-SIP-Calls",
"trunk_ids": [
"YOUR_INBOUND_TRUNK_ID"
],
"rule": {
"dispatchRuleIndividual": {
"roomPrefix": "call-"
}
},
"roomConfig": {
"egress": {
"room": {
"layout": "grid",
"fileOutputs": [
{
"filepath": "sip-recordings/{room_name}-{time}.mp4",
"s3": {
"bucket": "your-s3-bucket",
"region": "us-west-2",
"accessKey": "AWS_ACCESS_KEY_ID",
"secret": "AWS_SECRET_ACCESS_KEY"
}
}
]
}
}
}
}
Notes and quick requirements:
• Replace placeholders: YOUR_INBOUND_TRUNK_ID, S3 bucket, region, and AWS keys (use secure secrets in production).
• Egress service must be deployed and connected to the same Redis/LiveKit instance.
• API key used must have roomRecord permission.
• roomPrefix creates one room per call (e.g., call-abc123). The egress room block uses Room Composite egress to produce an MP4.
• You can instead use tracks or participant egress inside roomConfig.egress if you prefer per-track or per-participant files.
How to apply:
• CLI: save as dispatch-rule.json and run lk sip dispatch create dispatch-rule.json (or use the equivalent API call).
• Python SDK: populate CreateSIPDispatchRuleRequest with room_config.egress fields matching the JSON above.
If you want, I can:
• Convert this exact JSON into a ready-to-run Python SDK example that creates the trunk and dispatch rule and ensures S3 credentials are read from env vars. Which would you prefer? Sources: sip | livekit/livekit_composite | DeepWiki | SIP overview | LiveKit docs | examples/bank-ivr | livekit/livekit_composite | DeepWiki | Egress examples | LiveKit docs | Egress API | LiveKit docsechoing-lamp-18687
11/27/2025, 12:30 PMtall-airline-16756
11/27/2025, 12:30 PMechoing-lamp-18687
11/27/2025, 12:32 PMtall-airline-16756
11/27/2025, 12:32 PMechoing-lamp-18687
11/27/2025, 12:59 PMtall-airline-16756
11/27/2025, 1:00 PMechoing-lamp-18687
11/27/2025, 1:01 PMtall-airline-16756
11/27/2025, 1:01 PM