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.

Check it worked

Run the program with go run .. The deferred tp.Shutdown(ctx) flushes the spans when main returns. Then open your project in LangWatch: a new trace appears in the traces list within a few seconds, with the Azure OpenAI call as an LLM span carrying its input, output and token counts. If no trace appears, check that LANGWATCH_API_KEY is set in the environment the program runs in.
Last modified on October 29, 2026