Prerequisites
- Node.js 18+
- OpenAI TypeScript SDK (
npm install openai) - Maxim TypeScript SDK (
npm install @maximai/maxim-js) - API keys for OpenAI and Maxim
Environment Variables
Initialize Maxim Logger
Wrap OpenAI Realtime Client
Use thewrapOpenAIRealtime function to automatically trace all events in your Realtime session:
Add Custom Session Metadata
You can pass additional metadata to enrich your Realtime sessions with custom names and tags:Available Metadata Options
The third parameter towrapOpenAIRealtime accepts the following options:
| Option | Type | Description |
|---|---|---|
maxim-session-name | string | Custom name for the session displayed in the Maxim dashboard |
maxim-session-tags | Record<string, string> | string | Key-value pairs for filtering and organizing sessions |
maxim-session-id | string | Custom ID for the session (auto-generated if not provided) |
Basic Usage Example
Here’s a minimal example showing how to set up OpenAI Realtime with Maxim tracing:Cleanup
Always clean up resources when your session ends:What Gets Traced
The Maxim wrapper automatically captures:- Session lifecycle: Connection, configuration updates, and disconnection
- Audio events: Input/output audio buffers and transcriptions (if
audiomodality is enabled) - Conversation items: User messages, assistant responses, and function calls
- Tool calls: Function invocations and their results
- Errors: Any errors that occur during the session
View traces in the Maxim dashboard
Resources
OpenAI Realtime API
Official OpenAI Realtime documentation
Maxim JS SDK
Maxim TypeScript SDK on npm