Azure OpenAI Integration Guide¶
This guide covers Azure OpenAI configuration for Amplihack.
Configuration Reference¶
Required Variables¶
# Your Azure OpenAI API key
OPENAI_API_KEY="your-azure-openai-api-key-here" # pragma: allowlist secret
# Azure OpenAI endpoint URL with deployment and API version
OPENAI_BASE_URL="https://your-resource.openai.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2025-01-01-preview"
# Azure-specific settings
AZURE_OPENAI_KEY="your-azure-openai-api-key-here"
AZURE_API_VERSION="2025-01-01-preview"
Azure Endpoint URL Format¶
Your OPENAI_BASE_URL should follow this pattern:
https://<resource-name>.openai.azure.com/openai/deployments/<deployment-name>/chat/completions?api-version=<version>
Examples:
# GPT-4 deployment
OPENAI_BASE_URL="https://mycompany-ai.openai.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2025-01-01-preview"
# GPT-4o deployment
OPENAI_BASE_URL="https://eastus-openai.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview"
# Custom deployment name
OPENAI_BASE_URL="https://prod-ai.openai.azure.com/openai/deployments/my-gpt4-model/chat/completions?api-version=2025-01-01-preview"
# Azure Responses API (for structured output)
OPENAI_BASE_URL="https://mycompany-ai.openai.azure.com/openai/responses?api-version=2025-04-01-preview"
Troubleshooting¶
Authentication Errors¶
Error: 401 Unauthorized or 403 Forbidden
Solutions:
- Verify API key: Test with
curldirectly to Azure endpoint - Check permissions: Ensure key has access to the deployment
- Validate endpoint: Confirm deployment name and resource name
Connection Timeouts¶
Error: Request timed out or slow responses
Solutions:
- Check region: Use Azure region closest to your location
- Verify endpoint: Ensure the endpoint URL is correct
Model Not Found¶
Error: The model 'gpt-4' does not exist
Solutions:
- Check deployment name: Verify exact deployment name in Azure portal
- Update URL: Ensure
OPENAI_BASE_URLuses correct deployment
Security Best Practices¶
- Secure credentials: Never commit
.azure.envto git - Regular key rotation: Rotate Azure API keys periodically
- Monitor usage: Use Azure monitoring for API usage tracking
- Network security: Consider VPN/private endpoints for production
Support¶
Common Questions¶
Q: Does this work with Azure Government Cloud? A: Yes, use the appropriate Azure Government endpoints (e.g., *.azure.us).
Q: What Azure API versions are supported? A: The integration supports all current Azure OpenAI API versions. Use the latest stable version (e.g., 2025-01-01-preview) for best results.
Getting Help¶
If you encounter issues:
- Test direct connection: Use
curlto test Azure endpoint directly - Validate configuration: Use Azure portal to verify deployment names
- Update integration: Ensure you're using the latest version