# Azure OpenAI

> Connect an Azure OpenAI resource to ACOG, including Azure Government, and name deployments so ACOG can route to them by model.

Product: AI Cost Optimizer Gateway (ACOG). Web version: https://tessarac.com/docs/acog/providers/azure-openai. Last updated: 2026-10-16.

An Azure OpenAI connection calls the deployments in your own Azure OpenAI resource.

## Name deployments after their models

ACOG routes by model, and calls Azure at `{endpoint}/openai/deployments/<model>/chat/completions`. **Each deployment must be named exactly like the model it serves**, for example a deployment named `gpt-4o-mini` for the `gpt-4o-mini` model. A request for `gpt-4o-mini` then reaches that deployment.

## Connect

1. In the Azure portal, open your Azure OpenAI resource and copy its endpoint and one of its keys (**Keys and Endpoint**).
2. In ACOG, open **Admin → Providers → Connect provider**, choose **Azure** and **OpenAI**, and enter:

| Field | Example |
|---|---|
| Endpoint | `https://my-resource.openai.azure.com` (Azure Government: `https://my-resource.openai.azure.us`) |
| API version | `2024-10-21` |
| API key | One of the resource's keys |

3. Declare the deployment names as the connection's models and choose a default.

ACOG sends the key in the `api-key` header.

### Optional: let ACOG read which model each deployment serves

A deployment's name does not prove which model it runs. To bill and report on the model a deployment actually serves, give ACOG read access to the resource through Azure Resource Manager: the tenant ID, client ID and client secret of an app registration with the **Reader** role on the resource, and the subscription, resource group and account name. ACOG only reads deployment details with it.

## Azure Government

Azure Government (GCC High and DoD) resources use the `.openai.azure.us` endpoint. Nothing else changes.

## Calling Azure OpenAI through ACOG

- The [Chat Completions](https://tessarac.com/docs/acog/api/chat-completions.md) and [Embeddings](https://tessarac.com/docs/acog/api/embeddings.md) APIs, with the deployment name as the model.
- The [Messages API](https://tessarac.com/docs/acog/api/messages.md), translated.
- The Azure OpenAI API exactly as Azure defines it at the native route `https://gateway.acog.tessarac.com/azure`, with the gateway key in the `api-key` header. See [Native provider routes](https://tessarac.com/docs/acog/api/native-routes.md).

## Troubleshooting

| What you see | Cause | Fix |
|---|---|---|
| `404 DeploymentNotFound` from Azure | No deployment is named after the requested model | Create or rename the deployment to the model id |
| `422 model_access_required` | The model is not deployed in the resource | Deploy it, named after the model |
| `422 upstream_auth_failed` | Azure rejected the stored key | Paste a current key into the connection |
