Azure pass-through
The /azure and /azure_ai routes forward any Azure OpenAI or Azure AI path, such as /openai/deployments/{deployment}/chat/completions?api-version=2024-10-21, to Azure unchanged. Teams keep the Azure OpenAI SDK and the Azure API version they tested against, while the gateway holds the Azure key, checks the virtual key and records the spend. When a path segment names a deployment from model_list, the gateway routes through that deployment with its retries and fallbacks, otherwise it forwards to AZURE_API_BASE with the gateway's Azure key. Azure AI Search index operations on a gateway managed index are also served here, and creating a new index needs a proxy admin key.
A real-world scenario
A finance team's reporting tool uses the Azure OpenAI SDK with a fixed API version and an Azure key in its settings. The platform team registers the Azure deployment on the gateway, the tool sets its endpoint to https://gateway.example.com/azure and its key to a virtual key. The Azure key is gone from the tool, the team's budget applies, and the deployment can be moved between Azure regions on the gateway without touching the tool.
Before you start
The gateway needs an Azure credential and endpoint. It looks first for a model_list deployment of provider Azure whose deployment name appears in the path, then for the environment below.
| Variable | Purpose |
|---|---|
AZURE_API_KEY | The Azure key the gateway sends upstream. |
AZURE_API_BASE | The Azure resource endpoint, such as https://my-resource.openai.azure.com. |
Steps
-
Give the gateway the credential. Open
/ui/models-and-endpoints, on the Add Model tab pick Azure or Azure AI Foundry (Studio) under Provider, enter the deployment name, endpoint and key, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or setAZURE_API_KEYandAZURE_API_BASEand restart the gateway. -
Issue a virtual key on
/ui/api-keyswith + Create New Key, then Create Key. -
Call Azure through the gateway with the Azure path and API version.
curl -X POST "http://localhost:4000/azure/openai/deployments/gpt-6-1-sol/chat/completions?api-version=2024-10-21" \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "gpt-6.1-sol", "messages": [{"role": "user", "content": "Summarise this ticket in one sentence."}]}' -
With the Azure OpenAI SDK, set the endpoint to
http://localhost:4000/azureand the API key to the virtual key. -
Open
/ui/logsand click the newest row to see the request, the key and its cost.
Expected result
Azure's own response, with its status code and headers. Streaming is streamed through as it arrives.
{
"id": "chatcmpl-9f1c",
"object": "chat.completion",
"model": "gpt-6.1-sol",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "The customer wants one of two duplicate charges refunded."}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 18, "completion_tokens": 12, "total_tokens": 30}
}
The spend log row carries the key, team and user and the cost from usage.
Errors
| Status | Message | What it means and how to fix it |
|---|---|---|
401 | Authentication Error, Invalid proxy server token passed | The virtual key is missing, wrong, expired or blocked. |
403 | Key/team denied access to passthrough route /azure/... | The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team. |
403 | A message saying index management is limited to proxy admins | A non-admin key tried POST /indexes on Azure AI Search. Use a proxy admin key. |
500 | Required 'AZURE_API_BASE' in environment to make pass-through calls to Azure. | No deployment matched the path and no endpoint is set. Register the deployment or set AZURE_API_BASE and AZURE_API_KEY. |
| Any other | Azure's own error body | Azure refused the request. The message is returned unchanged. |
Related
Pass-through endpoints lists every built-in route. The unified chat completions endpoint works with every provider and runs guardrails. The Azure OpenAI and Azure AI provider pages cover the unified integrations, and Azure AI Speech pass-through covers speech to text.