Azure OpenAI
Trace Azure-hosted OpenAI deployments in Python and TypeScript.
Azure OpenAI is accessed through the OpenAI SDK's AzureOpenAI client. Wrapping it traces chat completions and the Responses API with provider="azure". In Python, embeddings, images, audio, and moderations are traced as well; the TypeScript wrapper covers chat completions and the Responses API.
Prerequisites
pip install -U "neatlogs[openai]" openaiUsage
import os
import neatlogs
from openai import AzureOpenAI
neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="azure-demo")
client = neatlogs.wrap(
AzureOpenAI(
api_key=os.environ["AZURE_OPENAI_API_KEY"],
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
api_version="2024-10-21",
)
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "In one sentence, what is Azure OpenAI?"}],
)
print(resp.choices[0].message.content)
neatlogs.flush()
neatlogs.shutdown()wrap() opens a WORKFLOW root for you, so this renders with no extra wrapper. Streaming is captured too — the wrapper sets stream_options.include_usage so token counts are recorded even for streamed responses.
Making several calls in one run? Group them into one trace with a
WORKFLOWroot.