This integration is in beta, so its API may change.
This setup requires
langsmith[livekit]>=0.11.2 and livekit-agents>=1.6.Install
Install the integration along with the LiveKit plugins your agent uses:Set environment variables
The integration reads your LangSmith credentials from the environment and exports to LangSmith for you via OpenTelemetry:.env
Set up tracing
Callconfigure_livekit once before creating your AgentServer.
configure_livekit() uses LiveKit session recordings by default. The record={"audio": True} option tells LiveKit to create the recording.
This setup works for both STT/LLM/TTS cascades and speech-to-speech (realtime) models. Realtime models need one extra call to capture the user’s transcript. For more information, see Use a realtime model.
Use your own tracer provider
If your application already manages an OpenTelemetryTracerProvider, add the LangSmith processor to that provider and register it with LiveKit:
Group a conversation into a thread
To group a conversation’s runs into a LangSmith thread, callset_thread_id inside the session handler. Use a unique ID for each active session:
Use a realtime model
For a speech-to-speech (realtime) model, callinstrument_session after creating the AgentSession to capture the user’s transcript. Pass the same thread ID to set_thread_id and instrument_session:
instrument_session for realtime models. STT/LLM/TTS cascades already capture the user’s transcript, so calling it there records each user turn twice.
Record the conversation audio
By default, the integration uses LiveKit’s session recording. Use Egress mode when you record to external storage instead.Record with LiveKit’s session recording
Turn on LiveKit’s session recording.In console mode, also pass
--record on the command line (python agent.py console --record). Without it LiveKit creates the recorder but never starts it, so there is no file to attach. The recording reflects what was played to the client, so a barge-in shows up truncated.Record with Egress
Use LiveKit Egress when you want the recording in your own object storage or need video. Egress recording delivery requires a thread ID. Configure the integration for Egress, then callcomplete_recording after the Egress file is available:
download_from_storage represents your storage client’s download operation. The default attachment name and MIME type are recording.ogg and audio/ogg. Set name or mime_type in complete_recording if your Egress output uses another format.
Always call
complete_recording, including on failure with data=None. Otherwise, the integration waits for recording_timeout_seconds (30 seconds by default) before exporting the trace without audio. Using complete_recording to capture Egress recordings requires setting a thread_id.Next steps
Voice fundamentals
Core conventions for tracing voice agents.
Upload files with traces
Attach the conversation audio recording to your trace.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

