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

# Azure AI Foundry

> Learn how to integrate Azure AI Foundry with Obiguard to access a wide range of AI models with enhanced observability and reliability features.

Azure AI Foundry provides a unified platform for enterprise AI operations, model building, and application development.
With Obiguard, you can seamlessly integrate with various models available on Azure AI Foundry and take advantage of features like observability, prompt management, fallbacks, and more.

## Understanding Azure AI Foundry Deployments

Azure AI Foundry offers three different ways to deploy models, each with unique endpoints and configurations:

1. **AI Services**: Azure-managed models accessed through Azure AI Services endpoints
2. **Managed**: User-managed deployments running on dedicated Azure compute resources
3. **Serverless**: Seamless, scalable deployment without managing infrastructure

You can learn more about the Azure AI Foundry deployment [here](https://learn.microsoft.com/en-us/azure/ai-foundry/concepts/deployments-overview).

<Card href="/integrations/llms/azure-openai" title="Azure OpenAI">
  If you're specifically looking to use OpenAI models on Azure, you might want to use [Azure OpenAI](/integrations/llms/azure-openai) instead, which is optimized for OpenAI models.
</Card>

## Integrate

To integrate Azure AI Foundry with Obiguard, you'll need to create a virtual key.
Virtual keys securely store your Azure AI Foundry credentials in Obiguard's vault,
allowing you to use a simple identifier in your code instead of handling sensitive authentication details directly.

Navigate to the Virtual Keys section in Obiguard and select "Azure AI Foundry" as your provider.

## Creating Your Virtual Key

You can create a virtual key for Azure AI Foundry using one of three authentication methods. Each method requires different information from your Azure deployment:

<Tabs>
  <Tab title="Default (API Key)">
    The recommended authentication mode using API Keys:

    Required parameters:

    * **API Key**: Your Azure AI Foundry API key

    * **Azure Foundry URL**: The base endpoint URL for your deployment, formatted according to your deployment type:
      * For AI Services: `https://your-resource-name.services.ai.azure.com/models`
      * For Managed: `https://your-model-name.region.inference.ml.azure.com/score`
      * For Serverless: `https://your-model-name.region.models.ai.azure.com`

    * **Azure API Version**: The API version to use (e.g., "2024-05-01-preview"). This is required if you have api version in your deployment url. For example:
      * If your URL is `https://mycompany-ai.westus2.services.ai.azure.com/models?api-version=2024-05-01-preview`, the API version is `2024-05-01-preview`

    * **Azure Deployment Name**: (Optional) Required only when a single resource contains multiple deployments.
  </Tab>

  <Tab title="Azure Managed Entity">
    For managed Azure deployments:

    Required parameters:

    * **Azure Managed ClientID**: Your managed client ID

    * **Azure Foundry URL**: The base endpoint URL for your deployment, formatted according to your deployment type:
      * For AI Services: `https://your-resource-name.services.ai.azure.com/models`
      * For Managed: `https://your-model-name.region.inference.ml.azure.com/score`
      * For Serverless: `https://your-model-name.region.models.ai.azure.com`

    * **Azure API Version**: The API version to use (e.g., "2024-05-01-preview"). This is required if you have api version in your deployment url.
      **Examples:**
      * If your URL is `https://mycompany-ai.westus2.services.ai.azure.com/models?api-version=2024-05-01-preview`, the API version is `2024-05-01-preview`

    * **Azure Deployment Name**: (Optional) Required only when a single resource contains multiple deployments.
  </Tab>

  <Tab title="Azure Entra ID">
    To use this authentication your azure application need to have the role of: `conginitive services user`.
    Enterprise-level authentication with Azure Entra ID:

    Required parameters:

    * **Azure Entra ClientID**: Your Azure Entra client ID

    * **Azure Entra Secret**: Your client secret

    * **Azure Entra Tenant ID**: Your tenant ID

    * **Azure Foundry URL**: The base endpoint URL for your deployment, formatted according to your deployment type:
      * For AI Services: `https://your-resource-name.services.ai.azure.com/models`
      * For Managed: `https://your-model-name.region.inference.ml.azure.com/score`
      * For Serverless: `https://your-model-name.region.models.ai.azure.com`

    * **Azure API Version**: The API version to use (e.g., "2024-05-01-preview"). This is required if you have api version in your deployment url.
      **Examples:**
      * If your URL is `https://mycompany-ai.westus2.services.ai.azure.com/models?api-version=2024-05-01-preview`, the API version is `2024-05-01-preview`

    * **Azure Deployment Name**: (Optional) Required only when a single resource contains multiple deployments. Common in Managed deployments.

    You can Learn more about these [Azure Entra Resources here](https://learn.microsoft.com/en-us/azure/ai-services/authentication)
  </Tab>
</Tabs>

## Sample Request

Once you've created your virtual key, you can start making requests to Azure AI Foundry models through Obiguard.

<Tabs>
  <Tab title="Python SDK">
    Install the Obiguard SDK with pip

    ```sh theme={null}
    pip install obiguard
    ```

    ```python theme={null}
    from obiguard import Obiguard

    client = Obiguard(
      obiguard_api_key="sk-obg***",  # Your Obiguard API key
      virtual_key = "AZURE_FOUNDRY_VIRTUAL_KEY"
    )

    response = client.chat.completions.create(
      model="DeepSeek-V3-0324", # Replace with your deployed model name
      messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Tell me about cloud computing"}
      ]
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="cURL">
    ```sh theme={null}
    curl https://gateway.obiguard.ai/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
      -H "x-obiguard-virtual-key: $AZURE_FOUNDRY_VIRTUAL_KEY" \
      -d '{
        "model": "DeepSeek-V3-0324",
        "messages": [
          { "role": "user", "content": "Tell me about cloud computing" }
        ]
      }'
    ```
  </Tab>
</Tabs>

## Advanced Features

### Function Calling

Azure AI Foundry supports function calling (tool calling) for compatible models. Here's how to implement it with Obiguard:

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    tools = [{
        "type": "function",
        "function": {
            "name": "getWeather",
            "description": "Get the current weather",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City and state"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location"]
            }
        }
    }]

    response = client.chat.completions.create(
        model="DeepSeek-V3-0324", # Use a model that supports function calling
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "What's the weather like in Delhi?"}
        ],
        tools=tools,
        tool_choice="auto"
    )

    print(response.choices[0])
    ```
  </Tab>
</Tabs>

### Vision Capabilities

Process images alongside text using Azure AI Foundry's vision capabilities:

<Tabs>
  <Tab title="Python S DK">
    ```python theme={null}
    response = client.chat.completions.create(
        model="Llama-4-Scout-17B-16E", # Use a model that supports vision
        messages=[
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What's in this image?"},
                    {
                        "type": "image_url",
                        "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                    },
                ],
            }
        ],
        max_tokens=500,
    )

    print(response.choices[0].message.content)
    ```
  </Tab>
</Tabs>

### Structured Outputs

Get consistent, parseable responses in specific formats:

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    response = client.chat.completions.create(
        model="cohere-command-a", # Use a model that supports response formats
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "List the top 3 cloud providers with their main services"}
        ],
        response_format={"type": "json_object"},
        temperature=0
    )

    import json
    print(json.loads(response.choices[0].message.content))
    ```
  </Tab>
</Tabs>

## Relationship with Azure OpenAI

For Azure OpenAI specific models and deployments, we recommend using the existing Azure OpenAI provider in Obiguard:

<Card title="Azure OpenAI Integration" icon="microsoft" href="/integrations/llms/azure-openai">
  Learn how to integrate Azure OpenAI with Obiguard for access to OpenAI models hosted on Azure.
</Card>
