> 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FHLfw0FdeiXqHrUagdcfF%2Fimage.png?alt=media&amp;token=6bed6aa5-4eb9-41a6-9bd3-d5b25be73f7d" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FKw9T5qBqkaxqGOZNjJwM%2Fimage.png?alt=media&amp;token=768c1feb-9692-4fb7-97a1-454b8223b569" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FcTEmvshVAygro7jiBSvq%2Fimage.png?alt=media&amp;token=50d89eed-6161-4671-a5ef-3dd32ef8cfb3" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FjJSHu3OLEmWO1ZXDGhcx%2Fimage.png?alt=media&amp;token=057e052a-ce8f-42c3-9aa4-94dc68bdedd1" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2Fb6lHr9DNGUaw2j9fh8zc%2Fimage.png?alt=media&amp;token=04e86662-52cc-443d-8643-c0ec6a3eb367" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2F1PEpbpQhW7avOMZjNmJ9%2Fimage.png?alt=media&amp;token=b803cf1b-f49d-47ee-a38a-0712e4063577" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FUW9O5kLme1kO2gtK7pRD%2Fimage.png?alt=media&amp;token=1fddd27b-7505-4500-b239-127f0359c71a" 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="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FlfAVgOb3AdY2pL09EKsV%2Fimage.png?alt=media&amp;token=3f9bc73a-fcd3-4e4a-a92d-741035ee00fd" 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 %}
