Skip to main content

Azure OpenAI

Language

Examples use Python. Beakpoint works with any language that OpenTelemetry supports.

Required Azure OpenAI Attributes

The following cost calculation tags are required for traces originating from Azure OpenAI API calls.

Always Required Fields

These fields are always required for Beakpoint to calculate Azure OpenAI costs:

Attribute NameExample ValueAllowed Values
gen_ai.systemazure.ai.openai or openaiEither value works (see detection paths below)
gen_ai.request.modelgpt-4.1Any valid OpenAI model name
gen_ai.usage.input_tokens512Non-negative integer
gen_ai.usage.output_tokens128Non-negative integer

Detection Paths

Beakpoint detects Azure OpenAI spans through two paths:

Pathgen_ai.systemserver.addressHow it works
Explicitazure.ai.openaiAny or absentAuto-instrumentation sets gen_ai.system = azure.ai.openai when using the AzureOpenAI client
ImplicitopenaiEnds with .openai.azure.comAuto-instrumentation sets gen_ai.system = openai, but the server address reveals it's Azure

In both cases, Beakpoint calculates costs using OpenAI rates because Azure OpenAI charges the same per-token pricing as the direct OpenAI API.

Optional Enrichment Attributes

These fields are optional but improve cost accuracy when provided:

Attribute NameExample ValueDescription
gen_ai.response.modelgpt-4.1-2025-04-14The exact model version returned in the response. When present, this takes precedence over gen_ai.request.model for pricing lookups.
gen_ai.usage.input_tokens.cached256Number of input tokens served from the prompt cache. Cached tokens are billed at a reduced rate.
gen_ai.usage.output_tokens.reasoning64Number of tokens used for internal reasoning (o-series models).
gen_ai.provider.nameazure.ai.openaiOTel semconv v1.37.0+ replacement for gen_ai.system. Takes precedence when both are present.
server.addressmydeployment.openai.azure.comEnables implicit detection when gen_ai.system = openai. Must end with .openai.azure.com for Azure identification.
cloud.providerazureCloud provider identifier.

Supported Models

Azure OpenAI serves the same models as the direct OpenAI API. See the OpenAI cost tags reference for the full list of supported models and pricing.

note

Date suffixes on Azure OpenAI deployment names (e.g. gpt-5.4-mini-2026-01-15) are automatically stripped during model name normalization.

Python Example

Azure OpenAI uses the same opentelemetry-instrumentation-openai-v2 package as direct OpenAI — the OpenAIInstrumentor handles both OpenAI and AzureOpenAI clients:

pip install opentelemetry-instrumentation-openai-v2
from opentelemetry.instrumentation.openai_v2 import OpenAIInstrumentor
from openai import AzureOpenAI

# Instrument before creating the client
# See the Track LLM Costs guide for complete TracerProvider setup
OpenAIInstrumentor().instrument()

client = AzureOpenAI(
azure_endpoint="https://mydeployment.openai.azure.com",
api_version="2025-04-01-preview",
)

response = client.chat.completions.create(
model="gpt-4.1",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)

The instrumentation automatically sets gen_ai.system, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, and the optional enrichment attributes from data the API response provides.

For full setup instructions, including how to configure the OpenTelemetry exporter for Beakpoint, see the Track LLM Costs guide.