Skip to main content
Trace OpenAI Responses API calls with Maxim to gain full observability into your LLM interactions, including tool calls and structured outputs.

Prerequisites

Environment Variables

Initialize Maxim Logger

Wrap OpenAI Client

Use MaximOpenAIClient to wrap your OpenAI client for automatic tracing:

Basic Usage

Make responses API requests using the wrapped client:

Tool Calling Example

Here’s an example demonstrating tool calls with the Responses API:

Responses API vs Chat Completions

The Responses API is a newer, simpler interface compared to Chat Completions:

Custom Headers for Tracing

You can pass custom headers to enrich your traces:

Available Header Options

Streaming Support

The wrapped client supports streaming responses:

Cleanup

Always clean up resources when done:

What gets logged to Maxim

  • Request Details: Model name, parameters, and all other settings
  • Message History: Complete conversation history including user messages and assistant responses
  • Response Content: Full assistant responses and metadata
  • Usage Statistics: Input tokens, output tokens, total tokens consumed
  • Error Handling: Any errors that occur during the request
Responses API Trace

Resources

OpenAI Responses API

Official OpenAI Responses API documentation

Maxim JS SDK

Maxim TypeScript SDK on npm