Integrations / Azure OpenAI
To trace Azure OpenAI with Tracify, wrap the AzureOpenAI client from the OpenAI library. Each request is recorded with the deployment name, tokens, latency and any error, such as a content-filter block.
Your code
Azure OpenAI
Tracify
One run.
Setup
Azure OpenAI uses the same library as OpenAI.
pip install tracify-sdk openaiCreate a project in Tracify, copy its API key and put it in the environment where your code runs. The SDK reads it from there, so nothing is hard-coded.
export TRACIFY_API_KEY="tracify_sk_live_..."AZURE_OPENAI_API_KEY is read by the OpenAI library as usual. The model you pass is your deployment name, and that is the name Tracify records.
import tracify
from openai import AzureOpenAI
azure = tracify.wrap_openai(AzureOpenAI(
azure_endpoint="https://your-resource.openai.azure.com",
api_version="2024-10-21",
))
reply = azure.chat.completions.create(
model="your-deployment-name",
messages=[{"role": "user", "content": "Hello"}],
)Same idea with the AzureOpenAI class from the openai package.
import { AzureOpenAI } from "openai";
import { wrapOpenAI } from "tracify-sdk";
const azure = wrapOpenAI(
new AzureOpenAI({
endpoint: "https://your-resource.openai.azure.com",
apiVersion: "2024-10-21",
}),
);
const reply = await azure.chat.completions.create({
model: "your-deployment-name",
messages: [{ role: "user", content: "Hello" }],
});Run your code one time, then open the Tracing page of your project. Your Azure call shows up as a run with its steps in order, plus the tokens, time and any error for each call.
Good to know
The wrapper reads the OpenAI call format, so calls are labeled as OpenAI-style in the trace. The model name you send is always the one shown, so you can still tell models apart.
Good to know
On Azure you call your own deployment name, which can be anything. Tracify shows that name. Because of that, give the wrapper your rates (see below) if you want a dollar cost per call.
Good to know
Tracify records the tokens the provider returns. A dollar cost is shown when you give the wrapper your own rates with calculate_cost (Python) or calculateCost (TypeScript), so the number always matches your real price plan.
Full details in the documentation. All integrations are listed on the integrations page.
