> For the complete documentation index, see [llms.txt](https://docs.mydbsync.com/cloud-workflow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mydbsync.com/cloud-workflow/ai/ai-agent-api-key-guides/azure-openai-api-key.md).

# Azure OpenAI API Key

Azure OpenAI Service delivers OpenAI models (such as `gpt-4o`, `gpt-4.1`, `o1`, and `gpt-4o-mini`) through Microsoft's Azure cloud. Unlike the direct OpenAI API, each Azure OpenAI resource has its own endpoint URL, its own set of API keys, and a per-deployment model name.

## Prerequisites

Before you begin, ensure that you have the following:

* An Azure account with an active subscription ($200 in free credit is available for new Azure accounts).
* Permissions in that subscription to create Azure resources and to deploy models.
* A region where the models that you want to use are available (model availability differs by region).

## Configure Azure OpenAI

{% stepper %}
{% step %}
Sign in to the [Azure portal](https://portal.azure.com/) with your Microsoft account. If you don't have an Azure subscription, click **Create a free account** and complete the sign-up process.

<div align="left" data-with-frame="true"><figure><img src="/files/hJ31P20ICdZXgZkIM1HA" alt="" width="299"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
Click **Create a resource**, search for `Azure OpenAI`, and then click **Create**.

<div data-with-frame="true"><figure><img src="/files/jsRQtFLNQDqmbQZ2DkXc" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/f4EVeZrBJ0lBX6zOskdg" alt=""><figcaption></figcaption></figure></div>

1. Enter the following:
   * **Subscription**
   * **Resource group** (new or existing)
   * **Region**: Select one where your target models are available, such as `East US`, `East US 2`, `West Europe`, or `Sweden Central`.
   * A unique **Name**: This becomes part of your endpoint URL. For example, `mycompany-ai` becomes `https://mycompany-ai.openai.azure.com/`.
   * **Pricing tier**: Set to `Standard S0`.
2. Click **Next**.

   <div data-with-frame="true"><figure><img src="/files/PfYqPETCHepjyCzUeoZ6" alt=""><figcaption></figcaption></figure></div>

{% endstep %}

{% step %}
Select the required **Type**. Click **Next**, then click **Create**.

<div align="left" data-with-frame="true"><figure><img src="/files/llaFuIGY4naRuNIxZFeG" alt="" width="317"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
Click the newly created Azure OpenAI resource, then click **Go to AI Foundry portal**.<br>

1. Click **View deployments**.<br>

   <div data-with-frame="true"><figure><img src="/files/BWp6hvvjZkvvgIFBFp0j" alt=""><figcaption></figcaption></figure></div>
2. Go to **Deploy** > **Deploy a base model**.
3. Select a model (such as `gpt-4o`, `gpt-4o-mini`, `gpt-4.1`, `o1`, `o3`, or any newer model listed for your region).
4. Click **Custom deploy**.
5. You can use the default deployment name or customize it as needed.

{% hint style="info" %}
**Note:** Record this deployment name. You must use it in the DBSync model field. Only deployed models are callable through the endpoint.
{% endhint %}

6. Click **Deploy**.
   {% endstep %}

{% step %}
In the Azure portal, open the Azure OpenAI resource, then click **Manage Keys**.

Copy **KEY 1** (or **KEY 2**) and the **Endpoint** URL.

<div data-with-frame="true"><figure><img src="/files/RgLQEpees0wpo7UtRAfK" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
Use `2024-10-21` for the API version.

For preview features (such as the newest models), use a preview version like `2025-01-01-preview`.
{% endstep %}

{% step %}
On the Azure OpenAI connector page, enter the API key, endpoint, and API version.<br>

<div data-with-frame="true"><figure><img src="/files/OEbwtHFfJpH6ipQOFGE4" alt=""><figcaption></figcaption></figure></div>

Click **Save Connection**, then click **Test Connection**.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
**Warning:** Each Azure OpenAI resource has its own keys and endpoint. If you delete the resource, you lose both keys. Regenerating a key in the Azure portal invalidates the previous value of that key slot (**KEY 1** or **KEY 2**) but leaves the other key working.
{% endhint %}

{% hint style="info" %}
**Tip:** Azure provides two keys per resource so you can rotate them without downtime. To rotate keys, point your application at **KEY 2**, regenerate **KEY 1** in the portal, update your application to use **KEY 1**, and then regenerate **KEY 2**.
{% endhint %}
