Azure OpenAI
Use OpenAI’s GPT-4o, GPT-4o-mini, o-series, and other models through Azure OpenAI Service. Same OpenAI capabilities, but authenticated with Azure credentials, billed through Azure, and deployed in your own Azure subscription with enterprise compliance.azureOpenai() uses the openai SDK’s built-in AzureOpenAI class. All OpenAI features — tool calling, streaming, JSON mode, vision, reasoning — work identically to the direct openai() provider.Setup
- Install
- Environment
The Azure OpenAI provider uses the same OpenAI SDK:
Factory
string
required
The model or deployment name. This is passed as the
model parameter to the API.AzureOpenAIConfig
Optional configuration. See Config below.
Supported Models
Deploying models on Azure
Deploying models on Azure
You must create a deployment for each model in the Azure AI Studio portal. The deployment name becomes the
modelId (or you can use config.deployment). See Azure OpenAI docs for setup instructions.Config
string
Azure OpenAI API key. Falls back to
AZURE_OPENAI_API_KEY env var.string
Azure OpenAI endpoint URL. Falls back to
AZURE_OPENAI_ENDPOINT env var. Format: https://<resource-name>.openai.azure.comstring
Deployment name. Falls back to
AZURE_OPENAI_DEPLOYMENT env var. If not set, modelId is used.string
default:"2024-10-21"
Azure API version. Falls back to
AZURE_OPENAI_API_VERSION env var.Authentication Methods
Method 1: API Key (Recommended)
Method 2: Explicit Config
Tool Calling
Tool calling works identically to the direct OpenAI provider:Reasoning Models (o-series)
Azure OpenAI supports the o-series reasoning models with the samereasoning config:
Multi-Modal Support
Azure OpenAI GPT-4o supports images, audio, and files — same as the direct OpenAI provider:Full Example
Azure OpenAI vs Direct OpenAI
Environment Variables
Cross-References
- OpenAI (Direct) — Direct OpenAI API with API key auth
- Azure AI Foundry — Open-source models (Phi, Llama, Mistral) on Azure
- Reasoning — O-series reasoning configuration
- Multi-Modal — Provider support matrix