many-forest-60185
12/26/2025, 2:14 PMtall-airline-16756
12/26/2025, 2:14 PMtall-airline-16756
12/26/2025, 2:14 PMstartRoomCompositeEgress call with a file.gcp output.
const { EgressClient } = require('livekit-server-sdk');
const egressClient = new EgressClient({
apiKey: process.env.LIVEKIT_API_KEY,
apiSecret: process.env.LIVEKIT_API_SECRET,
// optional: wsUrl if self-hosted, otherwise defaults to LiveKit cloud
wsUrl: process.env.LIVEKIT_WS_URL,
});
async function startGcpEgress() {
const resp = await egressClient.startRoomCompositeEgress({
roomName: 'my-room',
output: {
file: {
// template variables like ${room_name} and ${timestamp} are supported
filepath: 'recordings/${room_name}/${timestamp}.mp4',
gcp: {
bucket: 'your-gcp-bucket-name',
// optional: prefix within the bucket
pathPrefix: 'recordings/',
// optional: base64-encoded service account key if not using ADC
// serviceAccountKey: process.env.GCP_SERVICE_ACCOUNT_KEY_BASE64,
},
},
},
// optional settings
layout: 'speaker-dark',
audioOnly: false,
});
console.log('Egress started, id:', resp.egressId);
return resp;
}
startGcpEgress().catch(console.error);
Notes:
• output.file.gcp.bucket is required.
• If you don't use Application Default Credentials, include serviceAccountKey (base64) in gcp.
• Template variables in filepath (e.g., ${room_name}, ${timestamp}) are supported.
If you want an example for a different egress type (track-level, single-stream, or SRT/HLS outputs) or need help encoding the service account key, tell me which one and I’ll provide that snippet.
Sources: Universal Egress | server-sdk-js | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki