This integration is in beta, so its API may change.
Choose an approach
There are two ways to build with the OpenAI Realtime API, and LangSmith provides a tracing integration for each:- If you are connecting directly with the realtime client, use
wrap_realtime. - If you are building with the OpenAI Agents SDK, use
wrap_realtime_sessioninstead.
Install
Thelangsmith[openai-realtime]>=0.9.7 extra provides both wrappers:
Set environment variables
.env
Using the Realtime client
Use this when you open the WebSocket yourself withclient.realtime.connect() and drive the event loop.
Set up tracing
wrap_realtime returns a transparent proxy of your connection. Your existing async for event in connection loop, session.update, and tool handling stay the same:
Each conversation is captured as its own trace. To group it with related interactions in a LangSmith thread (for example to continue an earlier session or pick up from a text chat), pass a
thread_id. Reusing the same ID across traces links their events together.@traceable tools you run while handling an event nest under that event automatically.
Enable
input_audio_transcription and the agent transcript in your session.update in order to view a transcript as part of the trace.Record the conversation audio
When you feed the proxy your microphone and playback audio, it attaches a single stereo recording (user left, agent right) to the trace. To flag barge-ins, useis_agent_speaking:
You should record the agent’s audio from the speaker, so that the recording reflects only what was played. During a barge-in, generated audio is discarded before playback and should not be recorded. Doing this keeps the trace aligned with what the user actually heard.
Using the OpenAI Agents SDK
Use this when you build the agent with the OpenAI Agents SDK (RealtimeAgent / RealtimeRunner), which owns the turn and tool-call loop.
The Agents SDK’s built-in realtime tracing uploads to OpenAI’s own dashboard. Call
agents.set_tracing_disabled(True) to avoid a second, separate upload path.Set up tracing
wrap_realtime_session wraps the RealtimeSession and enters it for you. Iterate it as you would the original; the SDK runs tools and manages turns:
history snapshots, so messages appear even though the SDK streams them as partials.
Each conversation is captured as its own trace. To group it with related interactions in a LangSmith thread, for example to continue an earlier session or pick up from a text chat, pass a
thread_id. Reusing the same ID across traces links their events together.Record the conversation audio
Feed the proxy your microphone and playback audio:You should record the agent’s audio from the speaker, so that the recording reflects only what was played. During a barge-in, generated audio is discarded before playback and should not be recorded. Doing this keeps the trace aligned with what the user actually heard.
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.

