Integrations / Azure OpenAI

Trace Azure OpenAI deployments

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.

  • 01Deployment name used for each call
  • 02Token usage and latency
  • 03Content-filter and rate-limit errors
  • 04Calls grouped into the run that made them

Setup

5 steps.

  1. 01

    Install

    Azure OpenAI uses the same library as OpenAI.

    bash
    pip install tracify-sdk openai
  2. 02

    Set your project key

    Create 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.

    bash
    export TRACIFY_API_KEY="tracify_sk_live_..."
  3. 03

    Wrap the Azure client

    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.

    python
    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"}],
    )
  4. 04

    Or in TypeScript

    Same idea with the AzureOpenAI class from the openai package.

    typescript
    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" }],
    });
  5. 05

    Run it once and look

    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

Shown with the OpenAI label

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

Deployment names are not model names

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

About cost

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.

Does tracing Azure OpenAI change my requests or responses?
No. The wrapper passes your call straight through and records a copy. Your request, the response and any error reach your code unchanged.
Will I see content-filter blocks?
Yes. A blocked request raises an error in your code, and the same error is recorded on the span, so you can find every blocked call.
Does it work with managed identity instead of a key?
Yes. Authentication is handled by the AzureOpenAI client you create. Tracify only wraps the calls made through it.
Does the Responses API work too?
Yes. The wrapper records chat.completions and responses calls.

Send your first trace.

Free to start.