> For the complete documentation index, see [llms.txt](https://docs.raga.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.raga.ai/ragaai-catalyst/agentic-testing/concepts/tracing/ragaai-catalyst-tracing-guide-for-azure-openai-users.md).

# RagaAI Catalyst Tracing Guide for Azure OpenAI Users

This guide helps Azure OpenAI users implement RagaAI Catalyst's tracing capabilities to monitor, debug, and analyze their agentic applications.

### Prerequisites

* Python 3.10 or higher
* Azure OpenAI API access
* RagaAI Catalyst access credentials

### Quick Setup Guide

#### 1. Install RagaAI Catalyst

```bash
pip install ragaai-catalyst
```

#### 2. Set Up Tracing with Azure OpenAI

```python
from ragaai_catalyst import RagaAICatalyst, Tracer, init_tracing
from llama_index.llms.azure_openai import AzureOpenAI

# Initialize RagaAI Catalyst
catalyst = RagaAICatalyst(
    access_key="your_access_key",
    secret_key="your_secret_key",
)

# Create a tracer
tracer = Tracer(
    project_name="YourProjectName",  # Create this project in the RagaAI UI first
    dataset_name="YourDatasetName",
    tracer_type="agentic_tracing",  # Use appropriate tracer type ("agentic/llamaindex" for llamaindex examples)
)

# Initialize tracing
init_tracing(catalyst=catalyst, tracer=tracer)

# Create your Azure OpenAI instance
azure_llm = AzureOpenAI(
    azure_endpoint="https://your-resource-name.openai.azure.com/",
    model="your-deployment-name",  # e.g., "gpt-4o-mini"
    api_key="your-azure-openai-api-key",
    api_version="2024-05-01-preview",  # Use appropriate API version
    engine="your-deployment-name"  # Same as your deployment name
)

# Optional: Set model cost information for billing analysis
tracer.set_model_cost({
    "model_name": "gpt-4o-mini",
    "input_cost_per_million_token": 10_000_000,
    "output_cost_per_million_token": 20_000_000
})
```

### Tracing Methods

#### Using Decorators: Use decorators to trace specific functions in your application.

```python
from ragaai_catalyst import trace_llm, trace_tool, trace_agent

# Trace LLM calls
@trace_llm(name="azure_completion")
async def get_completion(prompt):
    response = await azure_llm.achat([ChatMessage(role="user", content=prompt)])
    return response.message.content

# Trace tool usage
@trace_tool(name="calculator_tool")
def calculate(x, y, operation):
    if operation == "add":
        return x + y
    elif operation == "multiply":
        return x * y
    # Add more operations as needed

# Trace agent behavior
@trace_agent(name="financial_advisor")
def advisor_agent(query, gt=None):  # Note: gt parameter for ground truth
    # Agent implementation
    return response
```

### Supported Trace Attributes

RagaAI Catalyst captures various attributes in your traces:

* User Input
* Agent Output
* Network Calls
* File Read/Write Operations
* Tool Calls
* LLM Calls (including Azure OpenAI)
* Custom Calls

### Accessing Trace Results

View your traces in the RagaAI Catalyst UI:

1. Log in to your RagaAI account
2. Navigate to your project
3. Select the dataset you specified in your code
4. View detailed traces showing each span (operation) within your application


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.raga.ai/ragaai-catalyst/agentic-testing/concepts/tracing/ragaai-catalyst-tracing-guide-for-azure-openai-users.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
