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

# Azure OpenAI

> Integrate Azure OpenAI with Agency Swarm to ensure secure data processing and enhanced privacy.

Many organizations prioritize data privacy and are cautious about sharing their data with any third-parties. By leveraging Azure OpenAI, you can ensure that your data is processed only within your own secure Azure environment, and not even shared with OpenAI itself.

<Info>
  Running OpenAI models on Azure is the same as deploying your own open source model on any other cloud provider.
</Info>

## Prerequisites

Before you begin, ensure you have the following:

1. Create an Azure Account with an active subscription. [Create an account here](https://azure.microsoft.com/en-us/free/).
2. Get approved access to the OpenAI Service on Azure.
3. Create an Azure OpenAI resource in [one of the available regions](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#assistants-preview) and deploy a model to it.
4. Obtain the endpoint URL and API key for the OpenAI resource.

## Setting Up Azure OpenAI with Agency Swarm

<Steps>
  <Step title="Configure the Azure OpenAI Client">
    To use Azure OpenAI, you need to configure the client to connect to your Azure OpenAI resource as follows:

    ```python theme={null}
    import os
    from openai import AsyncAzureOpenAI

    # Create a custom AsyncOpenAI client for Azure
    azure_agent = AsyncAzureOpenAI(
        api_key=os.getenv("AZURE_OPENAI_KEY"),
        azure_endpoint=os.getenv("AZURE_ENDPOINT"),
        api_version=os.getenv("AZURE_API_VERSION"),
    )
    ```
  </Step>

  <Step title="Update Agent Model Parameters">
    Set the `model` parameter inside each agent to use your custom client and model:

    ```python theme={null}
    from agency_swarm import Agent, OpenAIChatCompletionsModel

    # Define your agent and pass the custom client into the model
    azure_agent = Agent(
        name="AzureAgent",
        instructions="You are a helpful assistant",
        model=OpenAIChatCompletionsModel(
            model="gpt-5.6-luna",
            openai_client=azure_agent,
        ),
    )
    ```

    <Note>
      Model deployment name might be different from the standard OpenAI model names. It is set by you when you deploy a model to Azure.
    </Note>
  </Step>

  <Step title="Run Your Agency">
    After configuring the client and updating the agents, you can run your agency as usual:

    ```python theme={null}
    import asyncio
    from agency_swarm import Agency

    agency=Agency(azure_agent)

    agency.tui()
    ```

    The first terminal run downloads the matching terminal app automatically.
  </Step>
</Steps>

For other model providers (Anthropic, Google, AWS Bedrock, etc.), see [Third-Party Models](/additional-features/third-party-models).
