Skip to content

Commit 83f9d8d

Browse files
Boris Devclaude
authored andcommitted
feat: Add comprehensive Azure OpenAI support
This commit adds full Azure OpenAI integration to the proxy server, allowing users to route requests to Azure OpenAI deployments using the azure/ model prefix. ## Key Features Added: ### Server Integration (server.py): - Added Azure environment variables (AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, AZURE_API_VERSION, AZURE_DEPLOYMENT_NAME) - Enhanced API key selection logic to detect azure/ model prefix - Proper Azure credential and endpoint configuration for LiteLLM - Updated model validation to include Azure models - Azure models use OpenAI-compatible message processing - Fixed undefined endpoint variable issue in log_request_beautifully function - Added Azure model mapping for both small and big models - Improved error detail serialization for exceptions ### Environment Configuration (.env.example): - Added Azure OpenAI configuration section with examples - Clear documentation on azure/ model format usage - No default values for version/deployment (explicit configuration required) ### Test Suite: - test_azure_openai.py: Direct Azure OpenAI connectivity test using LiteLLM - test_azure_proxy.py: Proxy server Azure routing test ## Usage: Set Azure configuration in .env file, then use model format: azure/your-deployment-name ## Testing: - ✅ Direct Azure connection via LiteLLM - ✅ Proxy routing to Azure OpenAI - ✅ Token usage tracking - ✅ Error handling and validation - ✅ Response parsing and formatting ## Technical Details: - Uses same LiteLLM library for consistency - Explicit configuration (no defaults for version/deployment) - Proper error messages and validation - Clean separation from other providers - Compatible with existing OpenAI message processing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e9c8cf8 commit 83f9d8d

File tree

4 files changed

+927
-401
lines changed

4 files changed

+927
-401
lines changed

.env.example

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ PREFERRED_PROVIDER="openai"
1818
# Example Google mapping:
1919
# PREFERRED_PROVIDER="google"
2020
# BIG_MODEL="gemini-2.5-pro-preview-03-25"
21-
# SMALL_MODEL="gemini-2.0-flash"
21+
# SMALL_MODEL="gemini-2.0-flash"
22+
23+
# Azure OpenAI Configuration (optional)
24+
# Uncomment and set these if you want to use Azure OpenAI
25+
# Use model format: azure/your-deployment-name in requests
26+
# AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
27+
# AZURE_OPENAI_API_KEY="your-azure-openai-api-key"
28+
# AZURE_API_VERSION="2025-01-01-preview"
29+
# AZURE_DEPLOYMENT_NAME="gpt-4"

0 commit comments

Comments
 (0)