> For the complete documentation index, see [llms.txt](https://atlas.anywhere.now/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atlas.anywhere.now/product-reference/dialogue-studio/dialogue-studio-example-flows/connect-azure-openai.md).

# Connect to Azure OpenAI

Store Azure OpenAI credentials in global configuration and send a chat completion request from a Dialogue Studio flow.

This example connects Dialogue Studio to an Azure OpenAI deployment. It has two parts: a small configuration flow that stores your endpoint URL and API key in global context, and a simple chat flow that sends a message and shows the response in the debug sidebar.

## What it does

The configuration flow stores your Azure OpenAI URL and key once, so other flows (including the [simple voicebot example](/product-reference/dialogue-studio/dialogue-studio-example-flows/simple-voicebot-with-azure-openai.md)) can read them from global context. The request flow shows the minimum pattern for calling the Azure OpenAI chat completion API and reading the response.

## Prerequisites

* A UCC configured with Dialogue Studio.
* An Azure OpenAI resource. See [Azure OpenAI resource creation](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal).
* A deployed model in that resource, with its Target URI and Key available through your approved secret handling process.

## Deploy a model and retrieve an API key

1. Navigate to [Azure OpenAI](https://oai.azure.com/).
2. Ensure you have a resource. If not, see [Azure OpenAI resource creation](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal).
3. Go to **Shared resources > Deployments**.
4. If you already have a Text Completion model deployed, select it and skip to step 7.
5. If not, select **Deploy model > Deploy a Base Model**, choose a Text Completion model, and confirm.
6. Configure the deployment settings (deployment name, model version, tokens per minute rate limit) and select **Deploy**.
7. Once deployed, open it and, in the **Details** section, copy the **Target URI** and **Key**. You will use these in the Dialogue Studio flow.

## Import the configuration flow

1. Log in to your Dialogue Studio environment.
2. Import the JSON from [`flows/azure-openai-configuration.json`](https://github.com/AnywhereNow/atlas-docs/tree/main/product-reference/dialogue-studio/dialogue-studio-example-flows/flows/azure-openai-configuration.json) into the flow you prefer.
3. Open the **Configuration** function node and enter the URL and key you copied above.
4. Deploy the flow. The inject node's repeat setting automatically re-runs the configuration on a schedule, so the global value stays set.

{% hint style="warning" %}
Never paste a real API key into a flow you plan to export, share, or debug. Store the key using your organization's approved secret handling, and remove it before exporting or sharing this flow with anyone else.
{% endhint %}

## Import the request flow

1. Import the JSON from [`flows/azure-openai-request.json`](https://github.com/AnywhereNow/atlas-docs/tree/main/product-reference/dialogue-studio/dialogue-studio-example-flows/flows/azure-openai-request.json) into your flow.
2. Deploy the flow.
3. Select the inject node to trigger it.
4. Check the debug sidebar for the "Output: Simple Chat" response from Azure OpenAI.

## How the flows work

* **Configuration flow**: an inject node (once, then hourly) triggers a function node that calls `global.set("AzureOpenAI-Config", { apiKey, url })`, storing your credentials in global context for other flows to read.
* **Request flow**:
  * An inject node sends a test message (`what is 1 + 1 ?`) as `msg.payload`.
  * **Prepare request for OpenAI** (function node) reads `AzureOpenAI-Config.url` and `AzureOpenAI-Config.apiKey` from global context, builds the chat completion request headers (`Content-Type`, `api-key`) and payload (`messages`, `temperature`, `top_p`, `max_tokens`, and related parameters), and sets `msg.url`.
  * An **HTTP request** node posts the payload to Azure OpenAI.
  * A **Change** node extracts `payload.choices[0].message.content` from the response.
  * A **debug** node shows the extracted response.

## Safe fallback behavior

Neither flow includes an HTTP status check on the Azure OpenAI response. If you build on this pattern for a customer-facing flow, add a status code check (as used in the [Connect to ServiceNow](/product-reference/dialogue-studio/dialogue-studio-example-flows/connect-servicenow.md) and [Connect to Microsoft Graph as an application](/product-reference/dialogue-studio/dialogue-studio-example-flows/connect-microsoft-graph-application.md) examples) so a failed request produces a controlled fallback message instead of an unhandled error.

## Verification

1. Confirm the configuration flow's inject node has run at least once (check that `global.get("AzureOpenAI-Config")` returns your URL and a non-empty key indicator, without printing the key itself to any shared debug output).
2. Trigger the request flow's inject node and confirm a response appears in the "Output: Simple Chat" debug entry.
3. Confirm no API key appears in any debug output, exported flow, or shared screenshot.

## Related topics

* Go to [Simple voice bot (with Azure OpenAI)](/product-reference/dialogue-studio/dialogue-studio-example-flows/simple-voicebot-with-azure-openai.md) for a full call flow built on this configuration.
* Go to [Dialogue Studio example flows](/product-reference/dialogue-studio/dialogue-studio-example-flows.md) for the full gallery of example flows.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://atlas.anywhere.now/product-reference/dialogue-studio/dialogue-studio-example-flows/connect-azure-openai.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
