AI Model Providers
Azure AI Foundry
Enterprise-grade AI models with Azure security, compliance, and regional data residency. Access OpenAI, Llama, Mistral, and more through Azure infrastructure.
Overview
Azure AI Foundry (formerly Azure AI Studio) provides enterprise access to leading AI models. When integrated with Autohand, you get:
- Access to GPT-4, GPT-4o, and OpenAI models on Azure
- Open-source models like Llama 3.1, Mistral, and Phi
- Enterprise security with API Key, Microsoft Entra ID, or Managed Identity
- Data residency in your chosen Azure region
- Compliance certifications (SOC 2, HIPAA, GDPR)
- Private endpoints and VNet integration
Enterprise choice: Azure AI Foundry is ideal for organizations that need Azure compliance, regional data residency, or existing Azure infrastructure integration.
Setup
Get started with Azure AI Foundry.
Prerequisites
- Azure subscription with AI Foundry access
- Azure AI Foundry project created
- Model deployment in your project
Get your credentials
- Go to ai.azure.com and sign in
- Open your AI Foundry project
- Navigate to Deployments and select your model
- Copy the endpoint URL and API key
Configure Autohand
# Set environment variables
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_KEY="xxxxxxxxxxxxxxxxxxxxxxxx"
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
export AZURE_OPENAI_API_VERSION="2024-10-21"
# Or use the interactive wizard
autohand
/model
# Select "azure" from the provider list and follow the prompts
Verify your configuration:
# Start with Azure provider
autohand --provider azure --model gpt-4o
# Test with a prompt
autohand --prompt "Hello, which model are you?"
CLI configuration
Configure Azure AI Foundry in your ~/.autohand/config.json. Autohand supports two styles: structured fields (recommended) or a direct base URL override.
Structured configuration (recommended)
{
"provider": "azure",
"azure": {
"model": "gpt-4o",
"apiKey": "your-azure-api-key",
"resourceName": "your-resource",
"deploymentName": "gpt-4o",
"apiVersion": "2024-10-21",
"authMethod": "api-key"
}
}
Base URL override
For proxies, custom endpoints, or Azure AI Foundry model-as-a-service:
{
"provider": "azure",
"azure": {
"model": "gpt-4o",
"apiKey": "your-azure-api-key",
"baseUrl": "https://your-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21"
}
}
Configuration options
| Option | Description | Default |
|---|---|---|
model | Model name (for display and model switching) | gpt-4o |
apiKey | Your Azure API key | - |
resourceName | Azure resource name (from https://{name}.openai.azure.com) | - |
deploymentName | Model deployment name in Azure | - |
apiVersion | Azure OpenAI API version | 2024-10-21 |
authMethod | Authentication method: api-key, entra-id, or managed-identity | api-key |
baseUrl | Full endpoint URL override (bypasses resourceName/deploymentName) | - |
Environment variables
All configuration options can be set via environment variables. These override values in config.json:
| Variable | Maps to |
|---|---|
AZURE_OPENAI_KEY | azure.apiKey |
AZURE_OPENAI_ENDPOINT | azure.baseUrl |
AZURE_OPENAI_DEPLOYMENT | azure.deploymentName |
AZURE_OPENAI_API_VERSION | azure.apiVersion |
AZURE_TENANT_ID | azure.tenantId |
AZURE_CLIENT_ID | azure.clientId |
AZURE_CLIENT_SECRET | azure.clientSecret |
Authentication methods
Autohand supports three authentication methods for Azure OpenAI. Choose based on your security requirements.
API Key (default)
The simplest option. Use the API key from your Azure OpenAI resource.
{
"provider": "azure",
"azure": {
"authMethod": "api-key",
"apiKey": "your-azure-api-key",
"resourceName": "your-resource",
"deploymentName": "gpt-4o",
"apiVersion": "2024-10-21"
}
}
Microsoft Entra ID (Azure AD)
Use OAuth2 client credentials for enterprise environments. Requires an app registration in Microsoft Entra ID.
{
"provider": "azure",
"azure": {
"authMethod": "entra-id",
"tenantId": "your-tenant-id",
"clientId": "your-client-id",
"clientSecret": "your-client-secret",
"resourceName": "your-resource",
"deploymentName": "gpt-4o",
"apiVersion": "2024-10-21"
}
}
App permissions: Your Entra ID app registration needs the Cognitive Services OpenAI User role assigned on the Azure OpenAI resource.
Managed Identity
For workloads running inside Azure (VMs, App Service, AKS, etc.). No credentials needed — Azure handles authentication automatically via the Instance Metadata Service (IMDS).
{
"provider": "azure",
"azure": {
"authMethod": "managed-identity",
"resourceName": "your-resource",
"deploymentName": "gpt-4o",
"apiVersion": "2024-10-21"
}
}
Production recommended: Managed Identity is the most secure option for Azure-hosted workloads. No secrets to rotate or leak.
Available models
Azure AI Foundry supports multiple model families.
OpenAI models
| Model | Context | Best for |
|---|---|---|
gpt-4o | 128K | Most capable, multimodal |
gpt-4o-mini | 128K | Fast and cost-effective |
gpt-4-turbo | 128K | Complex reasoning |
Open-source models
| Model | Context | Best for |
|---|---|---|
Meta-Llama-3.1-70B | 128K | Open-source, flexible |
Mistral-Large-2 | 128K | Efficient reasoning |
Phi-3-medium | 128K | Microsoft research model |
Best practices
- Use Managed Identity: Prefer managed identities over API keys for Azure-hosted production workloads.
- Use Entra ID: For non-Azure environments, use Entra ID app credentials instead of API keys.
- Choose your region: Deploy models in regions that meet your data residency requirements.
- Monitor usage: Use Azure Cost Management to track AI spending.
- Set quotas: Configure TPM (tokens per minute) limits to control costs.
- Rotate API keys: If using API keys, rotate them regularly via the Azure portal.
Resources
Troubleshooting
Common issues
| Issue | Solution |
|---|---|
| 401 Unauthorized | Check API key or Azure AD credentials |
| 404 Deployment not found | Verify deployment name matches exactly |
| 429 Rate limited | Increase TPM quota in Azure portal |
| Region not available | Deploy model in a supported region |
Debug mode
# Enable verbose logging
AUTOHAND_DEBUG=true autohand --provider azure
# Test Azure endpoint directly
curl "https://your-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21" \
-H "api-key: ${AZURE_OPENAI_KEY}" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Hello"}]}'