The OpenAI Realtime integration is in development, so its API may change.
Choose an approach
There are two ways to build an OpenAI Realtime agent, and each has its own integration:
Both produce the same kind of trace. Pick the one that matches how you built your agent.
Install
Thelangsmith[openai-realtime] extra provides both wrappers:
sounddevice for microphone and speaker I/O.
Set environment variables
.env
Raw connection
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:
thread_id you generate per conversation (for example, a UUID) groups the trace into a LangSmith thread. Any @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, or the transcription events that make the trace readable never arrive.Record the conversation audio
Feed the proxy your microphone and playback audio, and it attaches a single stereo recording (user left, agent right) to the trace. Passis_agent_speaking so barge-ins are flagged:
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.
Record the conversation audio
Feed the proxy your microphone and playback audio: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.

