Skip to main content

Azure OpenAI

Overview

Azure OpenAI Service provides access to OpenAI's models through Microsoft Azure infrastructure. AI Gateway can be configured to use Azure OpenAI for various AI operations with your Azure infrastructure.

Configuration

To use Azure OpenAI, configure it in the Config Manager under the AI Gateway section:

ai:
providers:
azure:
apiKey: your-azure-api-key
resourceName: your-resource-name # Used in URL: https://{resourceName}.openai.azure.com/openai/v1
apiVersion: 2024-02-15-preview # Optional, defaults to preview
baseURL: https://ai-gateway.example.com/azure # Optional, to point at a gateway (overrides resourceName when provided)
headers: # Optional, e.g. for authentication with gateway
- key: X-Custom-Header
value: custom-value

Then set the default language model (using your Azure deployment name):

ai:
models:
languageModel: azure|your-deployment-name

Azure Setup

Prerequisites

  • Azure subscription with access to create Azure OpenAI resources
  • Model availability varies by region

1. Create Azure OpenAI Resource

  1. Sign in to Azure Portal
  2. Select "Create a resource" and search for "Azure OpenAI"
  3. Configure the resource:
    • Choose your subscription
    • Select or create a resource group
    • Choose a region
    • Name your resource
    • Select a pricing tier
  4. Complete the resource creation

2. Deploy a Model

  1. Sign in to Azure AI Foundry portal
  2. Select your subscription and OpenAI resource
  3. Navigate to "Deployments"
  4. Click "Create new deployment"
  5. Select a model (e.g., gpt-4, gpt-4o, gpt-35-turbo)
  6. Enter a deployment name (you'll use this in your configuration)
  7. Configure deployment settings
  8. Click "Create"

3. Get API Key and Resource Name

  1. In the Azure Portal, go to your Azure OpenAI resource
  2. Navigate to "Keys and Endpoint"
  3. Copy either KEY 1 or KEY 2
  4. Note your resource name from the resource overview

Example Configuration

ai:
providers:
azure:
apiKey: abc123...
resourceName: my-openai-resource
apiVersion: 2024-02-15-preview
models:
languageModel: azure|gpt-4-deployment # Use your deployment name, not the model name

Important Notes

  • Deployment Name vs Model Name: Use your deployment name in the configuration, not the underlying model name
  • API Version: Azure OpenAI uses API versions. The default is usually fine, but you can specify a specific version if needed
  • Resource Name vs Base URL: You can use either resourceName (simpler) or baseURL (for custom endpoints/gateways). When baseURL is provided, resourceName is ignored

For more information, refer to the Azure OpenAI documentation.