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.azure connection options and wire in azureopenai.Middleware via option.WithMiddleware:
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.Check it worked
Run the program withgo 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.
Related
- Go Integration Guide - Setup, manual spans, data capture and the REST client
- Go SDK API Reference - Instrumentation options and collected attributes
- Capturing Evaluations & Guardrails - Log evaluations and implement guardrails in your Azure OpenAI applications