Azure OpenAI Service provides access to OpenAI models through Microsoft’s Azure cloud. This guide shows you how to connect Azure OpenAI to the ngrok AI Gateway.Documentation Index
Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- ngrok account with AI Gateway access
- Azure OpenAI Service resource
- Deployed model in Azure OpenAI
Overview
Azure OpenAI uses a different URL structure than standard OpenAI. You configure the full deployment URL as thebase_url and the gateway routes requests to it.
Getting started
Get Azure OpenAI details
From the Azure Portal, gather:
- Endpoint URL:
https://your-resource.openai.azure.com - API Key: From “Keys and Endpoint” section
- Deployment Name: The name you gave your model deployment
Store your API key
Add your Azure OpenAI API key to ngrok secrets:
Configure the AI Gateway
Create a Traffic Policy with Azure OpenAI as a provider:
policy.yaml
Azure OpenAI requires the
api-version header. The headers configuration above ensures this is added to all requests.Advanced configuration
Multiple deployments
Configure multiple Azure OpenAI deployments:Multiple regions
Configure multiple Azure regions for failover:Without a model selection strategy, requesting
model: "gpt-4o" returns both regions as candidates (in config order), enabling failover. Requesting model: "azure-eastus:gpt-4o" pins to that region only. For explicit control over failover order, clients can use models: ["azure-eastus:gpt-4o", "azure-westus:gpt-4o"].Failover to OpenAI
Use Azure as primary with OpenAI fallback:The first strategy that returns models wins. If Azure has matching models, only those are tried. OpenAI is only used if no Azure models match. For cross-provider failover when requests fail, have clients specify multiple models:
models: ["azure-openai:gpt-4o", "openai:gpt-4o"].Embeddings
Configure Azure OpenAI embeddings:Troubleshooting
401 unauthorized
Symptom: Requests fail with authentication errors. Solutions:- Verify the API key is correct in secrets
- Check the key hasn’t been regenerated in Azure Portal
- Ensure the secret name matches your config
404 deployment not found
Symptom: Requests fail with deployment not found. Solutions:- Verify the deployment name in your
base_url - Check the deployment exists in Azure Portal
- Ensure the deployment is in the correct region
API version errors
Symptom: Requests fail with API version errors. Solutions:- Update the
api-versionheader to a supported version - Check Azure OpenAI API versions for current versions
Rate limiting
Symptom: 429 errors from Azure. Solutions:- Configure multiple deployments for failover
- Request quota increase in Azure Portal
- Add multiple API keys per deployment for automatic failover
Next steps
- Custom Providers - URL requirements and configuration
- Model Selection Strategies - Intelligent routing
- Multi-Provider Failover - Failover patterns