> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel-docs-benchmark-writeup-and-tooling.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure OpenAI

> Configure Azure OpenAI in GoModel using deployment-based URLs and the api-version query parameter.

Azure OpenAI speaks the OpenAI API shape with two GoModel-handled differences:
an `api-key` header instead of `Authorization: Bearer`, and a required
`api-version` query parameter on every request.

## Configure

```bash theme={null}
AZURE_API_KEY=...
AZURE_BASE_URL=https://your-resource.openai.azure.com/openai/deployments/your-deployment
AZURE_API_VERSION=2024-10-21   # optional, defaults to 2024-10-21
GOMODEL_MASTER_KEY=change-me
```

Or in `config.yaml`:

```yaml theme={null}
providers:
  azure:
    type: azure
    base_url: "${AZURE_BASE_URL}"
    api_key: "${AZURE_API_KEY}"
    api_version: "2024-10-21"
```

## Run GoModel

<CodeGroup>
  ```bash Docker (.env file) theme={null}
  docker run --rm -p 8080:8080 --env-file .env enterpilot/gomodel
  ```

  ```bash Docker (inline -e) theme={null}
  docker run --rm -p 8080:8080 \
    -e GOMODEL_MASTER_KEY="change-me" \
    -e AZURE_API_KEY="..." \
    -e AZURE_BASE_URL="https://your-resource.openai.azure.com/openai/deployments/your-deployment" \
    enterpilot/gomodel
  ```

  ```bash Binary (make build) theme={null}
  make build
  ./bin/gomodel
  ```
</CodeGroup>

## Verify

```bash theme={null}
curl -s http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer $GOMODEL_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5",
    "messages": [{"role": "user", "content": "Reply with the single word ok."}],
    "max_tokens": 80
  }'
```

`GET /v1/models` returns the deployments the Azure resource exposes with
`owned_by: "azure"`. Streaming, Responses, embeddings, and batches all work the
same way; batch results route through the `/openai/batches` resource path.

## Multiple deployments

Each Azure deployment is its own endpoint. Register them as separate providers
with suffixed env vars:

```bash theme={null}
AZURE_GPT5_API_KEY=...
AZURE_GPT5_BASE_URL=https://your-resource.openai.azure.com/openai/deployments/gpt-5

AZURE_EMBED_API_KEY=...
AZURE_EMBED_BASE_URL=https://your-resource.openai.azure.com/openai/deployments/text-embedding-3-small
```

This registers `azure-gpt5` and `azure-embed`. To expose every deployment under
one resource through a single provider, point `AZURE_BASE_URL` at the resource
root (no `/deployments/...`) and use [virtual models](/features/virtual-models) or
`AZURE_MODELS` to advertise specific deployment names.

## Notes

* GoModel accepts the deployment-scoped URL the portal hands you. For
  account-wide operations (model listing, batches) GoModel strips the
  `/openai/deployments/<deployment>` suffix automatically, so one
  `AZURE_BASE_URL` covers both chat and resource-level calls.
* `AZURE_API_VERSION` only needs to be set explicitly when you need a different
  stable or preview version — for example a newer Responses API surface.

## Troubleshooting

* **`401 Unauthorized` / `403`** — `AZURE_API_KEY` does not match the resource
  hosting the deployment, or the deployment name in the URL is wrong.
* **`Resource not found` / `DeploymentNotFound`** — the model in the request
  body must be the deployment name, not the underlying base model.
* **`unsupported api version`** — bump `AZURE_API_VERSION` to a version the
  feature you're calling supports. Newer Responses API features require recent
  preview versions.

## References

* [Azure OpenAI REST API versioning](https://learn.microsoft.com/azure/ai-services/openai/reference)
* [Azure OpenAI deployments](https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource)
* [Azure OpenAI authentication](https://learn.microsoft.com/azure/ai-services/openai/how-to/managed-identity)
