Skip to main content
LangWatch provides native instrumentation for Azure OpenAI accessed through the official openai-go/v3 client’s azure subpackage. The azureopenai module is a thin wrapper over the OpenAI instrumentation: all of OpenAI’s chat / responses / embeddings capture applies unchanged, and the provider is recorded as azure.openai.

Installation

Usage

Set LANGWATCH_API_KEY, AZURE_OPENAI_API_KEY, and AZURE_OPENAI_ENDPOINT environment variables before running.
Build the Azure client with the azure connection options and wire in azureopenai.Middleware via option.WithMiddleware:
Set AZURE_OPENAI_ENDPOINT to your Azure OpenAI resource endpoint (e.g., https://your-resource.openai.azure.com); the Model you pass is your deployment name.
The middleware captures input and output content by default (langwatch.DataCaptureAll). Pass azureopenai.WithDataCapture(langwatch.DataCaptureNone) to opt out.
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