Skip to main content
LangWatch provides automatic instrumentation for the official openai-go/v3 client library through a dedicated middleware that captures detailed information about your OpenAI API calls. It handles Chat Completions, the Responses API and Embeddings, with full streaming support.

Installation

Usage

Set LANGWATCH_API_KEY and OPENAI_API_KEY environment variables before running.
The middleware automatically captures request/response content, every token type (input / output / cached / reasoning), and model information. Streaming responses are fully supported and automatically accumulated.
The middleware captures input and output content by default (langwatch.DataCaptureAll). To opt out, pass otelopenai.WithDataCapture(langwatch.DataCaptureNone) (or DataCaptureInput / DataCaptureOutput to capture only one side).
The defer tp.Shutdown(ctx) call is essential. Without it, traces buffered in memory will be lost when your application exits.
Last modified on September 8, 2026