Does LiveKit have native GCS egress support?
# ask-ai
m
Does LiveKit have native GCS egress support?
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — regarding native GCS egress: yes. LiveKit’s EgressClient can export recordings/streams directly to Google Cloud Storage. Supported egress types include: • Room composite egress — record an entire room and export to a GCS bucket. • Track composite egress — export synchronized audio+video tracks for a participant to GCS. • Track egress — export individual raw tracks to GCS. If you’d like, tell me which egress type you plan to use and your preferred SDK (server SDK/JS or other) and I’ll provide the exact API call and required GCS parameters. Sources: server-sdk-js | livekit/livekit_composite | DeepWiki | Use Case: Video Conferencing | LiveKit
m
Node JS exmaple please. give example clal
t
Thanks — responding to your request for a Node.js example call to start LiveKit egress to Google Cloud Storage (GCS). Below is a concise Node.js example that starts a Room Composite egress and writes the resulting MP4 to a GCS bucket. Replace placeholders (
LIVEKIT_URL
,
API_KEY
,
API_SECRET
,
your-gcs-bucket
) with your values and provide GCP credentials via
credentials_json
or
GOOGLE_APPLICATION_CREDENTIALS
.
Copy code
// npm install livekit-server-sdk
const {
  EgressClient,
  RoomCompositeEgressRequest,
  GCPUpload,
  RoomCompositeEgressRequest_Output,
  RoomCompositeEgressRequest_File
} = require('livekit-server-sdk');

const LIVEKIT_URL = '<wss://LIVEKIT_URL>';
const API_KEY = 'API_KEY';
const API_SECRET = 'API_SECRET';

const egressClient = new EgressClient(LIVEKIT_URL, API_KEY, API_SECRET);

async function startRoomCompositeToGCS() {
  const request = new RoomCompositeEgressRequest({
    room_name: 'my-room',
    layout: 'speaker-dark',
    audio_only: false,
    video_only: false,
    file: new RoomCompositeEgressRequest_File({
      filename: 'recordings/my-room-${timestamp}.mp4',
      output: new RoomCompositeEgressRequest_Output({
        $case: 'gcp',
        gcp: new GCPUpload({
          bucket: 'your-gcs-bucket',
          // Optional: provide service account JSON string if not using env var
          // credentials_json: JSON.stringify(require('./gcp-service-account.json')),
        }),
      }),
    }),
  });

  try {
    const info = await egressClient.startRoomCompositeEgress(request);
    console.log('Egress started, egress_id:', info.egress_id);
    return info.egress_id;
  } catch (err) {
    console.error('Failed to start egress:', err);
    throw err;
  }
}

// Example: call and optionally stop after some time
(async () => {
  const egressId = await startRoomCompositeToGCS();
  // To stop later:
  // await egressClient.stopEgress(egressId);
})();
If you want an example for Track egress or Track Composite egress instead, or need the exact shape for providing inline
credentials_json
, tell me which one and I’ll provide it. Sources: server-sdk-js | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki