Skip to main content
LangWatch provides automatic instrumentation for the official openai-go client library through a dedicated middleware that captures detailed information about your OpenAI API calls.

Installation

Usage

Set LANGWATCH_API_KEY and OPENAI_API_KEY environment variables before running.
The middleware automatically captures request/response content, token usage, and model information. Streaming responses are fully supported and automatically accumulated.
The defer tp.Shutdown(ctx) call is essential. Without it, traces buffered in memory will be lost when your application exits.