1. Install the SDK
Install the latest compatible release in the repo where your livekit worker runs. Use the package manager the repo already uses.livekit-agents>=1.6.6,<1.9, including LiveKit 1.8. It uses OpenAI Python 2. Check compatibility with the worker’s existing dependencies before upgrading and keep the resolved versions in the repo’s lockfile.
2. Setup the worker’s environment
Use an egma API key scoped to the project you want to send data to. You can create it through the CLI or the UI.-
CLI: from a repo with a logged-in egma CLI and the right project in
egma/config.yaml, run the command below. Useegma loginif you need to sign in, andegma initif the repo does not have a project setup yet. - UI: open your project in egma, go to Settings → API keys, enter a name, select your project under Scope, and click Create key.
3. Add the integration
There are two functions depending on what you want to setup.A. Simulation testing
Call and awaitsimulation(agent, ctx, session) after creating the agent and session, before session.start. Add this around the existing start call in your job entrypoint:
## Mock tools in the test. Other tools run their real implementations and are recorded too.
The SDK recognises simulation rooms by the egma-sim- prefix. In other rooms, simulation does nothing. Keep that prefix reserved for egma simulations.
For text simulations, disable audio and transcription pacing in egma-sim-chat- rooms. Use this start call, keeping your normal voice settings in the other branch:
await simulation(...) call before this start call. Turn off any separate audio publishers in the text branch too.
If the worker cannot complete the handshake with egma, simulation raises NotReported. Fix the setup before starting the session. If a mocked tool cannot reach egma during a simulation, that tool errors instead of calling the real backend.
simulation has no total startup deadline. It waits for Egma to join and accept the tool configuration while the simulation room stays active. A room disconnect, Egma participant departure, or task cancellation stops the wait. Each RPC attempt keeps its own transport timeout, and transient registration or delivery failures are retried with the same configuration.
When the configured simulation ends, Egma finishes its pending output and leaves the room. The SDK then closes the AgentSession that you supplied. An abrupt room disconnect closes it too. This completes LiveKit’s native session trace and lets an entrypoint that waits for session close finish without its own timer. The listener is installed only after the exact Egma participant has accepted the tool report, and it is never installed in a production room.
B. Production monitoring
Callmonitor(ctx) at the start of the job entrypoint, before ctx.connect and session.start:
monitor(ctx) at the start of the entrypoint, then await simulation(agent, ctx, session) before the session starts. Both use the same environment settings.
The SDK adds egma to a compatible existing OpenTelemetry provider. Keep LiveKit’s default of one job per process, so each job’s traces stay attached to its own room.
4. Run the updated worker and verify
For simulations, register the agent and a connection in egma if you have not already done so. Start the updated worker with an explicitagent_name matching that connection. Supply the job dispatch metadata your worker needs for startup.
Keep a local worker running during tests. To use a cloud worker, deploy the SDK changes and environment settings there first. A successful local run does not deploy those changes.
- Testing: run a simulation, wait for it to finish, and check that it completed with the agent’s POV. If the agent calls a mocked tool, check its recorded arguments and answer too.
- Monitoring: make a production conversation and check that it appears in egma Monitoring.
EGMA_URL, and the worker’s export logs.