> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure OpenAI

> Add HoneyHive observability to your Azure OpenAI applications

[Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/) provides OpenAI models hosted on Azure infrastructure. HoneyHive integrates with Azure OpenAI using the same OpenInference OpenAI instrumentor, automatically capturing all API calls, tool use, and token usage.

## Quick Start

<Tip>
  **Add HoneyHive tracing in just 4 lines of code.** Azure OpenAI uses the same `openai` Python package and the same instrumentor as standard OpenAI.
</Tip>

<Tip>
  To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see [Tracer Initialization](/v2/tracing/tracer-initialization).
</Tip>

```bash theme={null}
pip install "honeyhive[openinference-azure-openai]"

# Or install separately
pip install honeyhive openinference-instrumentation-openai openai azure-identity
```

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.openai import OpenAIInstrumentor

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
)
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

# Your existing Azure OpenAI code works unchanged
```

<Note>
  Azure OpenAI uses the standard `openai` Python package with the `AzureOpenAI` client class. The same `OpenAIInstrumentor` works for both.
</Note>

### Tested Versions

HoneyHive's Azure OpenAI integration is tested against the following versions on PyPI, as of May 2026. Newer patch releases are generally safe; if you hit an issue, pin to these versions to reproduce a known-good configuration.

| Package                                | Version     |
| -------------------------------------- | ----------- |
| `openinference-instrumentation-openai` | `>= 0.1.0`  |
| `openai`                               | `>= 1.0.0`  |
| `azure-identity`                       | `>= 1.12.0` |

Requires Python 3.11+.

## What Gets Traced

The instrumentor automatically captures:

* **Chat completions** - `client.chat.completions.create()` with inputs, outputs, and token usage
* **Tool / function calls** - Each tool call with arguments and results
* **Embeddings** - `client.embeddings.create()` requests
* **Streaming responses** - Streamed completions with aggregated tokens

No manual instrumentation required.

***

## Example: Basic Chat Completion

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.openai import OpenAIInstrumentor
from openai import AzureOpenAI

tracer = HoneyHiveTracer.init(project="your-project")
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

client = AzureOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    api_version="2024-10-21",
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT", ""),
)

response = client.chat.completions.create(
    model="gpt-4o-mini",  # Your deployment name
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"},
    ],
)
print(response.choices[0].message.content)
```

***

## Environment Configuration

```bash theme={null}
# HoneyHive configuration
export HH_API_KEY="your-honeyhive-api-key"
export HH_PROJECT="your-project"

# Azure OpenAI configuration
export AZURE_OPENAI_API_KEY="your-azure-openai-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
```

***

## Troubleshooting

### Traces not appearing

1. **Check environment variables** - Ensure `HH_API_KEY` and `HH_PROJECT` are set
2. **Pass the tracer provider** - The instrumentor must receive `tracer_provider=tracer.provider`:

```python theme={null}
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.openai import OpenAIInstrumentor

tracer = HoneyHiveTracer.init(project="your-project")

# ✅ Correct - pass tracer_provider
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

# ❌ Wrong - missing tracer_provider
OpenAIInstrumentor().instrument()
```

3. **Initialize before making calls** - Call `instrument()` before creating the `AzureOpenAI` client

### Deployment name vs model name

In Azure OpenAI, the `model` parameter is your **deployment name**, not the underlying model name:

```python theme={null}
response = client.chat.completions.create(
    model="my-gpt4-deployment",  # This is your Azure deployment name
    messages=[{"role": "user", "content": "Hello"}],
)
```

***

## Related

<CardGroup cols={2}>
  <Card title="OpenAI Integration" icon="robot" href="/v2/integrations/openai">
    Standard OpenAI API integration
  </Card>

  <Card title="Enrich Your Traces" icon="sparkles" href="/v2/tutorials/enriching-traces">
    Add user IDs and custom metadata to traces
  </Card>

  <Card title="Distributed Tracing" icon="share-nodes" href="/v2/tutorials/distributed-tracing">
    Trace calls across service boundaries
  </Card>
</CardGroup>

***

## Using Traceloop (OpenLLMetry) Instead

If your project already uses [Traceloop / OpenLLMetry](https://github.com/traceloop/openllmetry), you can use its OpenAI instrumentor instead of OpenInference. The setup is identical - only the install and import paths differ.

```bash theme={null}
pip install "honeyhive[traceloop-azure-openai]"

# Or install separately
pip install honeyhive opentelemetry-instrumentation-openai openai azure-identity
```

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from openai import AzureOpenAI

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
)
OpenAIInstrumentor().instrument(tracer_provider=tracer.provider)

client = AzureOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    api_version="2024-10-21",
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT", ""),
)

response = client.chat.completions.create(
    model="gpt-4o-mini",  # Your deployment name
    messages=[{"role": "user", "content": "What is the capital of France?"}],
)
print(response.choices[0].message.content)
```

### Tested Versions

| Package                                | Version              |
| -------------------------------------- | -------------------- |
| `opentelemetry-instrumentation-openai` | `>= 0.58.0, < 1.0.0` |
| `openai`                               | `>= 1.0.0`           |
| `azure-identity`                       | `>= 1.12.0`          |

***

## Resources

* [Azure OpenAI Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/)
* [OpenInference OpenAI Instrumentor](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-openai)
