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

# Azure OpenAI

> Using Moda with Azure OpenAI Service

## Overview

Azure OpenAI Service provides access to OpenAI models hosted on Azure infrastructure. Since the Azure OpenAI client extends the standard OpenAI client, Moda automatically tracks your Azure OpenAI calls with the same setup as standard OpenAI.

## Setup with Moda SDK

<CodeGroup>
  ```python Python theme={"dark"}
  import moda
  from openai import AzureOpenAI

  moda.init("YOUR_MODA_API_KEY")

  client = AzureOpenAI(
      api_key="YOUR_AZURE_API_KEY",
      api_version="2024-02-01",
      azure_endpoint="https://your-resource.openai.azure.com",
  )

  moda.conversation_id = "session_123"

  response = client.chat.completions.create(
      model="gpt-4o",  # This is your deployment name
      messages=[{"role": "user", "content": "Hello!"}]
  )

  moda.flush()
  ```

  ```typescript Node.js theme={"dark"}
  import { Moda } from 'moda-ai';
  import { AzureOpenAI } from 'openai';

  await Moda.init('YOUR_MODA_API_KEY');

  const client = new AzureOpenAI({
    apiKey: 'YOUR_AZURE_API_KEY',
    apiVersion: '2024-02-01',
    endpoint: 'https://your-resource.openai.azure.com',
  });

  Moda.conversationId = 'session_123';

  const response = await client.chat.completions.create({
    model: 'gpt-4o',  // This is your deployment name
    messages: [{ role: 'user', content: 'Hello!' }]
  });

  await Moda.flush();
  ```
</CodeGroup>

<Note>
  The `model` parameter for Azure OpenAI is your **deployment name**, not the model name. Moda captures whatever value you pass as the model identifier.
</Note>

## Azure-Specific Configuration

| Parameter                     | Description                               |
| ----------------------------- | ----------------------------------------- |
| `azure_endpoint` / `endpoint` | Your Azure OpenAI resource URL            |
| `api_version` / `apiVersion`  | Azure API version (e.g., `2024-02-01`)    |
| `api_key` / `apiKey`          | Azure OpenAI API key                      |
| `model`                       | Your deployment name (not the model name) |

## Supported Features

| Feature                     | Captured |
| --------------------------- | -------- |
| Chat completions            | Yes      |
| Streaming                   | Yes      |
| Function calling / tool use | Yes      |
| Embeddings                  | Yes      |
| Token usage                 | Yes      |

## Troubleshooting

**Model name shows deployment name instead of actual model?**

* This is expected with Azure OpenAI. The `model` field will contain your deployment name.

**Authentication errors?**

* Verify your `api_key`, `api_version`, and `azure_endpoint` are correct
* Ensure the deployment exists in your Azure OpenAI resource

<Info>
  For full SDK documentation, see the [Python SDK](/ingestion/moda-sdk) or [Node.js SDK](/ingestion/moda-sdk-node) guides.
</Info>
