LiveKit (tracing)

LiveKit Agents emits structured spans for agent sessions, model calls, and tool execution. Use Respan’s LiveKit instrumentation to emit them through the Respan tracing pipeline.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

Setup

1

Install packages

$pip install respan-ai respan-instrumentation-livekit livekit-agents
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
3

Initialize and run

1import os
2
3from livekit.agents import llm
4from respan import Respan, workflow
5from respan_instrumentation_livekit import LiveKitInstrumentor
6
7respan = Respan(
8 api_key=os.environ["RESPAN_API_KEY"],
9 app_name="livekit-tracing",
10 instrumentations=[LiveKitInstrumentor()],
11)
12
13
14@workflow(name="livekit_chat.workflow")
15async def run_chat(model: llm.LLM) -> str:
16 chat_ctx = llm.ChatContext.empty()
17 chat_ctx.add_message(role="user", content="Say hello in one sentence.")
18 response = await model.chat(chat_ctx=chat_ctx).collect()
19 return response.text
20
21respan.shutdown()

Pass livekitModule when your app imports @livekit/agents directly. This ensures the instrumentor patches the same LiveKit module instance your application uses.

4

View your trace

Open the Traces page and look for agent sessions, agent turns, LLM nodes, function tools, user turns, handoffs, and TTS spans generated from LiveKit agent execution.

Captured data

DataDescription
Agent sessionsLiveKit AgentSession spans and lifecycle context.
Agent turnsUser and assistant turn activity.
LLM nodesModel input and generated content.
Function toolsTool names, arguments, outputs, and errors.
HandoffsAgent transfers represented through LiveKit tool events.
TTS spansText-to-speech spans emitted by LiveKit.