Skip to main content
Azure OpenAI Service provides enterprise-ready deployment of OpenAI models with Microsoft Azure’s security, compliance, and regional availability.

Installation

Azure OpenAI support is included in the base installation:

Prerequisites

  • Azure OpenAI Resource: Deployed in Azure Portal
  • Model Deployments: Deploy your chosen models (e.g., gpt-4.1, text-embedding-3-small)
  • API Keys: Retrieve from Azure Portal

Configuration

Environment Variables

.env

Basic Setup

Initialize Graphiti with Azure OpenAI:

API Endpoint Format

Azure OpenAI uses a different endpoint structure than OpenAI: Correct format:
Important notes:
  • Use the v1 API endpoint (/openai/v1/)
  • The standard AsyncOpenAI client works with Azure’s v1 API
  • Deployment names (not model names) are used in requests

Supported Models

Language Models

Deploy any of these models in Azure:
  • gpt-4.1: Latest GPT-4.1 model
  • gpt-4.1-mini: Cost-effective mini model
  • gpt-5-mini: Reasoning model with extended thinking
  • gpt-5: Advanced reasoning model
  • gpt-4o: Optimized GPT-4
  • o1, o3: Specialized reasoning models

Embedding Models

  • text-embedding-3-small: 1536 dimensions, cost-effective
  • text-embedding-3-large: 3072 dimensions, highest quality
  • text-embedding-ada-002: Legacy model

Model Deployment Names

In Azure, you create deployments with custom names for each model:

Configuration Options

LLM Client

Embedder Client

Structured Output Support

Azure OpenAI supports structured outputs: For regular models (GPT-4o, etc.):
  • Uses beta.chat.completions.parse API
  • Native Pydantic model validation
For reasoning models (GPT-5, o1, o3):
  • Uses responses.parse API
  • Supports reasoning and verbosity parameters

Reasoning Models Configuration

For GPT-5, o1, and o3 models:
Note: Reasoning models don’t support temperature parameter.

Complete Example

Error Handling

Graphiti automatically handles:
  • Rate Limit Errors: Exponential backoff and retry
  • Validation Errors: Automatic retry with error context
  • Refusal Errors: Content policy violations (no retry)
  • API Errors: Network and service errors

When to Use Azure OpenAI

Choose Azure OpenAI if you:
  • Need enterprise compliance (SOC 2, HIPAA, etc.)
  • Want regional data residency
  • Require private network access (VNet integration)
  • Need Azure Active Directory authentication
  • Want cost management through Azure subscriptions
  • Require Service Level Agreements (SLAs)
Choose Standard OpenAI if you:
  • Want access to the latest models immediately
  • Don’t need enterprise compliance features
  • Prefer simpler setup and pricing

Regional Availability

Azure OpenAI is available in multiple regions:
  • East US, East US 2
  • West US, West US 2, West US 3
  • North Europe, West Europe
  • UK South
  • And more…
Check Azure OpenAI regions for current availability.

Rate Limits and Quotas

Azure OpenAI uses Tokens Per Minute (TPM) quotas:
.env
Monitor usage in Azure Portal to adjust concurrency.

Security Best Practices

  • Use Managed Identity: Avoid API keys in production
  • Enable Private Endpoints: Restrict network access
  • Configure Azure AD: Use role-based access control
  • Enable Audit Logging: Track all API usage
  • Rotate Keys: Regularly rotate API keys

Cost Management

  • Use Provisioned Throughput: For predictable costs
  • Monitor Usage: Set up Azure cost alerts
  • Use Mini Models: Lower costs for simpler tasks
  • Batch Operations: Reduce API calls

Monitoring and Logging

Enable Azure Monitor for:
  • Request/response logging
  • Performance metrics
  • Cost tracking
  • Error analysis