The Azure AI Integration API provides seamless integration with Microsoft Azure AI services, including Azure OpenAI, Azure Cognitive Services, and Azure Machine Learning for enhanced code analysis, generation, and AI-powered development workflows.
POST /api/v1/azure-ai/openai/configure
Configures Azure OpenAI service integration for code generation and analysis.
{
"endpoint": "https://your-resource.openai.azure.com/",
"api_key": "your_azure_openai_api_key",
"api_version": "2024-02-15-preview",
"deployments": [
{
"name": "gpt-4",
"model": "gpt-4",
"deployment_id": "gpt-4-deployment",
"capabilities": ["code_generation", "code_analysis", "documentation"]
},
{
"name": "gpt-35-turbo",
"model": "gpt-35-turbo",
"deployment_id": "gpt-35-deployment",
"capabilities": ["code_completion", "quick_analysis"]
}
],
"default_deployment": "gpt-4",
"rate_limits": {
"requests_per_minute": 120,
"tokens_per_minute": 120000
}
}
{
"success": true,
"configuration_id": "azure_openai_12345",
"endpoint": "https://your-resource.openai.azure.com/",
"deployments_configured": 2,
"status": "active",
"last_tested": "2025-06-17T10:30:00Z",
"test_results": {
"connection": "successful",
"authentication": "valid",
"deployments": {
"gpt-4": "available",
"gpt-35-turbo": "available"
}
}
}
POST /api/v1/azure-ai/openai/generate
Generates code using Azure OpenAI models.
{
"deployment": "gpt-4",
"prompt": "Create a Python function that validates email addresses",
"language": "python",
"context": {
"existing_code": "import re\n\n# Existing validation functions",
"requirements": ["RFC 5322 compliance", "return boolean"],
"style_guide": "PEP 8"
},
"parameters": {
"temperature": 0.3,
"max_tokens": 1000,
"top_p": 0.95,
"frequency_penalty": 0.0,
"presence_penalty": 0.0
}
}
{
"success": true,
"generation_id": "gen_67890",
"deployment_used": "gpt-4",
"generated_code": "def validate_email(email: str) -> bool:\n \"\"\"\n Validates an email address according to RFC 5322.\n \n Args:\n email (str): The email address to validate\n \n Returns:\n bool: True if email is valid, False otherwise\n \"\"\"\n pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'\n return re.match(pattern, email) is not None",
"metadata": {
"tokens_used": 156,
"processing_time_ms": 1250,
"model_version": "gpt-4-0613",
"finish_reason": "stop"
},
"quality_metrics": {
"syntax_valid": true,
"style_compliance": 95,
"security_score": 100,
"performance_rating": "good"
}
}
POST /api/v1/azure-ai/cognitive/configure
Configures Azure Cognitive Services for enhanced code analysis.
{
"services": {
"text_analytics": {
"endpoint": "https://your-resource.cognitiveservices.azure.com/",
"api_key": "your_text_analytics_key",
"enabled": true
},
"translator": {
"endpoint": "https://api.cognitive.microsofttranslator.com/",
"api_key": "your_translator_key",
"enabled": true
},
"speech": {
"endpoint": "https://your-region.stt.speech.microsoft.com/",
"api_key": "your_speech_key",
"enabled": false
}
},
"default_language": "en-US",
"fallback_language": "en"
}
{
"success": true,
"configuration_id": "azure_cognitive_54321",
"services_configured": 2,
"services_active": ["text_analytics", "translator"],
"status": "active",
"last_tested": "2025-06-17T10:30:00Z"
}
POST /api/v1/azure-ai/cognitive/sentiment
Analyzes sentiment in code comments and documentation.
{
"texts": [
"# TODO: This is a terrible hack that needs to be fixed",
"# Excellent implementation of the algorithm",
"# This function works but could be optimized"
],
"language": "en",
"include_confidence": true
}
{
"success": true,
"results": [
{
"text": "# TODO: This is a terrible hack that needs to be fixed",
"sentiment": "negative",
"confidence_scores": {
"positive": 0.05,
"neutral": 0.10,
"negative": 0.85
},
"analysis": {
"issues_detected": ["technical_debt", "urgent_todo"],
"priority": "high",
"suggestion": "Consider prioritizing this refactoring task"
}
},
{
"text": "# Excellent implementation of the algorithm",
"sentiment": "positive",
"confidence_scores": {
"positive": 0.92,
"neutral": 0.06,
"negative": 0.02
},
"analysis": {
"issues_detected": [],
"priority": "low",
"suggestion": "Well-documented code"
}
}
]
}
POST /api/v1/azure-ai/cognitive/translate
Translates code comments and documentation between languages.
{
"texts": [
"# Cette fonction valide les adresses email",
"# 这个函数验证电子邮件地址"
],
"source_language": "auto",
"target_language": "en",
"preserve_formatting": true
}
{
"success": true,
"translations": [
{
"original_text": "# Cette fonction valide les adresses email",
"translated_text": "# This function validates email addresses",
"detected_language": "fr",
"confidence": 0.98
},
{
"original_text": "# 这个函数验证电子邮件地址",
"translated_text": "# This function validates email addresses",
"detected_language": "zh-Hans",
"confidence": 0.95
}
]
}
POST /api/v1/azure-ai/ml/configure
Configures Azure Machine Learning workspace for custom model deployment.
{
"workspace_name": "aurelis-ml-workspace",
"resource_group": "aurelis-resources",
"subscription_id": "your_subscription_id",
"region": "eastus",
"authentication": {
"type": "service_principal",
"tenant_id": "your_tenant_id",
"client_id": "your_client_id",
"client_secret": "your_client_secret"
},
"compute_targets": [
{
"name": "code-analysis-cluster",
"type": "AmlCompute",
"vm_size": "Standard_D3_v2",
"min_nodes": 0,
"max_nodes": 4
}
]
}
{
"success": true,
"workspace_id": "aml_workspace_99999",
"workspace_url": "https://ml.azure.com/workspaces/workspace-id",
"status": "configured",
"compute_targets_created": 1,
"available_models": []
}
POST /api/v1/azure-ai/ml/deploy
Deploys a custom AI model for specialized code analysis.
{
"model_name": "code-quality-analyzer",
"model_version": "1.0.0",
"model_file": "model.pkl",
"environment": {
"name": "aurelis-env",
"python_version": "3.8",
"dependencies": [
"scikit-learn==1.0.2",
"pandas==1.3.0",
"numpy==1.21.0"
]
},
"deployment_config": {
"instance_type": "Standard_DS2_v2",
"instance_count": 1,
"endpoint_name": "code-quality-endpoint"
}
}
{
"success": true,
"deployment_id": "deploy_88888",
"endpoint_url": "https://code-quality-endpoint.eastus.inference.ml.azure.com/score",
"status": "deploying",
"estimated_completion": "2025-06-17T10:45:00Z",
"swagger_url": "https://code-quality-endpoint.eastus.inference.ml.azure.com/swagger.json"
}
POST /api/v1/azure-ai/ml/predict
Makes predictions using deployed Azure ML models.
{
"endpoint_name": "code-quality-endpoint",
"input_data": {
"code_snippet": "def calculate_average(numbers):\n return sum(numbers) / len(numbers)",
"language": "python",
"context": {
"file_type": "function",
"complexity": "low",
"line_count": 2
}
}
}
{
"success": true,
"prediction_id": "pred_77777",
"predictions": {
"quality_score": 8.5,
"maintainability": 9.0,
"readability": 8.8,
"performance": 7.5,
"security": 9.2,
"issues": [
{
"type": "potential_bug",
"severity": "medium",
"description": "Division by zero possible if empty list provided",
"suggestion": "Add input validation for empty lists"
}
]
},
"confidence": 0.92,
"processing_time_ms": 150
}
POST /api/v1/azure-ai/safety/analyze
Analyzes code and comments for potentially harmful content.
{
"content": [
"# This password validation is terrible",
"def hack_system():",
"# Regular validation function"
],
"categories": ["hate", "violence", "sexual", "self_harm"],
"severity_threshold": "low"
}
{
"success": true,
"results": [
{
"content": "# This password validation is terrible",
"flagged": false,
"categories": {
"hate": {"severity": 0, "flagged": false},
"violence": {"severity": 0, "flagged": false},
"sexual": {"severity": 0, "flagged": false},
"self_harm": {"severity": 0, "flagged": false}
}
},
{
"content": "def hack_system():",
"flagged": true,
"categories": {
"hate": {"severity": 0, "flagged": false},
"violence": {"severity": 2, "flagged": true},
"sexual": {"severity": 0, "flagged": false},
"self_harm": {"severity": 0, "flagged": false}
},
"recommendation": "Review function name for potential security implications"
}
]
}
GET /api/v1/azure-ai/analytics
Retrieves usage analytics for Azure AI services.
{
"success": true,
"period": "last_30_days",
"services": {
"azure_openai": {
"requests": 15420,
"tokens_consumed": 2450000,
"average_response_time_ms": 1250,
"cost_usd": 245.50,
"deployments": {
"gpt-4": {
"requests": 8520,
"tokens": 1800000,
"cost_usd": 180.00
},
"gpt-35-turbo": {
"requests": 6900,
"tokens": 650000,
"cost_usd": 65.50
}
}
},
"cognitive_services": {
"text_analytics": {
"requests": 5420,
"cost_usd": 54.20
},
"translator": {
"characters_translated": 125000,
"cost_usd": 12.50
}
},
"machine_learning": {
"inference_requests": 2840,
"compute_hours": 45.5,
"cost_usd": 68.25
}
},
"total_cost_usd": 380.45,
"rate_limit_hits": 12,
"error_rate": 0.02
}
Recommended for production environments:
{
"tenant_id": "your_tenant_id",
"client_id": "your_client_id",
"client_secret": "your_client_secret"
}
For Azure OpenAI and Cognitive Services:
{
"api_key": "your_service_api_key",
"endpoint": "https://your-resource.cognitiveservices.azure.com/"
}
400
: Invalid request parameters or malformed data401
: Authentication failed or invalid API key403
: Insufficient permissions or quota exceeded404
: Resource or deployment not found429
: Rate limit exceeded500
: Azure service error or internal server error{
"success": false,
"error": {
"code": "AZURE_QUOTA_EXCEEDED",
"message": "Azure OpenAI quota exceeded for this deployment",
"details": {
"service": "azure_openai",
"deployment": "gpt-4",
"quota_type": "tokens_per_minute",
"limit": 120000,
"used": 120000,
"reset_time": "2025-06-17T10:35:00Z"
}
}
}
Rate limits vary by Azure service:
curl -X POST "https://api.aurelis.dev/v1/azure-ai/openai/configure" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"endpoint": "https://your-resource.openai.azure.com/",
"api_key": "your_azure_openai_key",
"deployments": [
{
"name": "gpt-4",
"model": "gpt-4",
"deployment_id": "gpt-4-deployment"
}
]
}'
curl -X POST "https://api.aurelis.dev/v1/azure-ai/openai/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"deployment": "gpt-4",
"prompt": "Create a Python function for email validation",
"language": "python",
"parameters": {"temperature": 0.3}
}'
curl -X POST "https://api.aurelis.dev/v1/azure-ai/cognitive/sentiment" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"texts": ["# This code needs improvement"],
"language": "en"
}'
from aurelis import AzureAIIntegration
azure_ai = AzureAIIntegration(api_key="your_api_key")
# Configure Azure OpenAI
azure_ai.configure_openai(
endpoint="https://your-resource.openai.azure.com/",
api_key="azure_openai_key",
deployments=[
{
"name": "gpt-4",
"model": "gpt-4",
"deployment_id": "gpt-4-deployment"
}
]
)
# Generate code
result = azure_ai.generate_code(
deployment="gpt-4",
prompt="Create a function for email validation",
language="python"
)
# Analyze sentiment
sentiment = azure_ai.analyze_sentiment([
"# This code is excellent",
"# TODO: Fix this terrible bug"
])
# Configure Azure OpenAI
aurelis azure-ai configure openai \
--endpoint https://your-resource.openai.azure.com/ \
--api-key your_key
# Generate code
aurelis azure-ai generate \
--deployment gpt-4 \
--prompt "Create email validation function" \
--language python
# Analyze sentiment
aurelis azure-ai sentiment "This code needs improvement"
Supported Azure regions for optimal performance:
Azure AI services support various compliance standards:
For Azure AI integration issues: