Skip to main content
LiveKit Agents is a framework for building real-time voice and video AI applications. Braintrust traces LiveKit Agents applications to capture voice interactions, agent sessions, and realtime model usage.
To trace LiveKit Agents with Braintrust’s TypeScript SDK, use OpenTelemetry.

OpenTelemetry

Braintrust attaches to LiveKit’s built-in OpenTelemetry pipeline by registering a span processor with LiveKit’s tracer provider.

Setup

1

Install dependencies

@livekit/agents is built against OpenTelemetry JS 1.x. Keep every OpenTelemetry package on its 1.x-compatible version, as pinned above. Upgrading any of them to 2.x breaks LiveKit at build or run time. The OTLP exporter packages use a separate 0.x version sequence that moves in step with the stable 1.x packages, so @opentelemetry/exporter-trace-otlp-http pins to ^0.57 rather than ^1.
2

Set your environment variables

.env

Configure tracing

Configure Braintrust’s span processor and set it as LiveKit’s tracer provider.
livekit_agent.ts

What Braintrust traces

These spans come from LiveKit’s native OpenTelemetry instrumentation. With the OpenAI realtime model, the LLM, speech-to-text, and text-to-speech work happens inside a single realtime model call rather than as separate spans.
  • Session spans (agent_session), the root span covering the full agent session
  • Agent turn spans (agent_turn), with the model request, token usage, and realtime model metrics (gen_ai.*, lk.realtime_model_metrics)
  • User speaking spans (user_speaking), with participant and speech detection details
  • Agent speaking spans (agent_speaking), covering the agent’s spoken response
  • Activity lifecycle spans (start_agent_activity, on_enter, on_exit, drain_agent_activity)

Tracing resources