Launch Week 3: Five days of launches

LiveKit Agents

Use Confident AI for LLM observability and evals for LiveKit Agents

Overview

LiveKit Agents is a framework for building realtime voice and multimodal agents in Python and TypeScript.

The integration works through OpenTelemetry. LiveKit emits native spans for sessions, turns, model requests, tools, and speech timing; confident-trace, Confident AI's OpenTelemetry-native tracing SDK, exports those spans to Confident AI with their parent-child relationships intact.

Call init() at the top of your agent file. You don't need to wrap your agent or add a tracing callback to each session.

RuntimeRequirementsSetup
PythonPython 3.10+, livekit-agents (tested with 1.8.3)Call init() at module scope, before starting the agent server
TypeScriptNode.js 22+, @livekit/agents >=1.9.0 <2Call init() at module scope and start the worker with the preload

Auto-Instrument

  1. Install Dependencies

    Add confident-trace to your existing LiveKit agent project. Keep the model plugins your agent already uses.

    pip install confident-trace 'livekit-agents==1.8.3'

    If you're starting a new agent, follow the LiveKit quickstart first, then add the tracing setup below.

  2. Set Your API Key

    Get your Confident AI Project API key and make it available to your agent server and its worker processes:

    export CONFIDENT_API_KEY="<your-confident-project-key>"

    Keep your existing LiveKit credentials and model provider keys configured as usual.

  3. Instrument Your Agent

    Add init() at module scope in the file LiveKit loads for each job, before starting the server. Keep your existing session, model, and tool configuration.

    agent.py
    from confident_trace import init
    from livekit.agents import AgentServer, JobContext, cli
    
    init()
    server = AgentServer()
    
    
    @server.rtc_session()
    async def entrypoint(ctx: JobContext):
        await ctx.connect()
        # Keep your existing AgentSession setup and agent logic here.
    
    
    if __name__ == "__main__":
        cli.run_app(server)
  4. Run Your Agent

    python agent.py dev

    Use start instead of dev for production. Connect to your agent as usual, then open the Observatory in your Confident AI project to inspect its traces.

    Confident flushes pending spans after LiveKit finishes job cleanup, including spans completed by asynchronous shutdown callbacks. You don't need to add a separate flush callback. Allow graceful worker shutdown; a forced process kill can still lose pending spans.

What Gets Captured

The integration exports the native spans LiveKit emits, labelled LiveKit:

  • Session and job lifecycle — the hierarchy and timing of work within a call.
  • User and agent turns — conversational activity within the session.
  • Model requests — model details and token usage when emitted by the model plugin.
  • Tool calls — tool execution and the attributes LiveKit records for it.
  • Speech timing — speaking, end-of-turn detection, and text-to-speech spans where available.
  • Errors — error status recorded on native spans.

When LiveKit's native model spans are exported through Confident's provider, the integration suppresses overlapping provider spans so each model call is recorded once. Supported provider calls outside those native model spans can still be traced separately.

Existing OpenTelemetry Providers

If LiveKit hasn't been given a tracer provider, the integration connects it to Confident's provider. It preserves providers explicitly configured with Python's telemetry.set_tracer_provider() or TypeScript's telemetry.setTracerProvider().

If you've configured a separate LiveKit provider, its native spans continue to use that provider. They aren't automatically copied to Confident AI. Configure export on that provider using the OpenTelemetry setup guide, or let this integration configure LiveKit's provider for you.

In TypeScript, the OpenAI 6 client used by LiveKit's OpenAI plugin is also supported by Confident's automatic provider instrumentation. This can capture model calls when LiveKit uses a separate provider, but does not copy the session, speech, or tool spans from that provider.

Content Privacy

LiveKit controls the content on its native spans. Set this before starting your worker to disable LiveKit's conversation-content capture:

export LIVEKIT_TELEMETRY_ALLOW_PII=0

Confident's capture_content / captureContent and redaction options apply to Confident-generated spans; they do not scrub LiveKit's native span attributes. Configure both layers when using LiveKit alongside directly instrumented model clients.

Disable LiveKit Instrumentation

Pass init() a list of integration identifiers to enable only those integrations. The LiveKit identifier is "livekit" in both Python and TypeScript. Omit it to disable the adapter; an empty list disables all automatic instrumentation:

from confident_trace import init

init(instrumentations=())

This disables Confident's automatic adapter, including its LiveKit cleanup flush. LiveKit can still emit native OpenTelemetry spans through its configured provider. LiveKit is optional: applications that don't install it can use init() normally.

Next Steps

Need help instrumenting your application?Connect your model calls and agent workflows to Confident AITalk to an expert

Last updated on

Built byConfident AI