Overview
TheAzureOpenAIEmbedderClient provides embeddings using OpenAI models hosted on Azure, supporting both the native Azure OpenAI SDK and OpenAI’s v1 API compatibility endpoint.
Installation
Basic Usage
Constructor
AsyncAzureOpenAI | AsyncOpenAI
required
Pre-configured Azure OpenAI client. Must be either:
AsyncAzureOpenAIfor native Azure SDKAsyncOpenAIwith Azure v1 API endpoint
str
default:"'text-embedding-3-small'"
Azure deployment name for the embedding model.
Unlike
OpenAIEmbedder, this client does NOT support embedding dimension configuration. It returns embeddings in their native dimensions.Azure SDK Setup
Option 1: AsyncAzureOpenAI (Recommended)
Option 2: AsyncOpenAI with Azure v1 Endpoint
Supported Models
All OpenAI embedding models available on Azure:- text-embedding-3-small (1536 dims)
- text-embedding-3-large (3072 dims)
- text-embedding-ada-002 (1536 dims, legacy)
Use your Azure deployment name as the
model parameter, not the base model name.Methods
create()
Generate a single embedding vector.input_data(str | list[str] | Any): Input to embed
list[float] - Embedding vector in native dimensions
Input handling:
- String: Direct embedding
- List of strings: Embeds all, returns first
- Other types: Converts to string
create_batch()
Generate embeddings for multiple texts.input_data_list(list[str]): List of texts to embed
list[list[float]] - List of embedding vectors
Input Type Handling
The embedder handles different input types:Error Handling
- Authentication errors: Invalid API key or endpoint
- Deployment not found: Wrong deployment name
- Rate limit errors: Quota exceeded
- Input validation errors: Invalid input format
Dimension Handling
UnlikeOpenAIEmbedder, this client does NOT truncate dimensions:
Batch Processing
Efficiently process multiple texts:Example: Document Embedding
Use with Graphiti
Comparison with OpenAIEmbedder
Performance Tips
- Use batch processing: Always prefer
create_batch()for multiple inputs - Monitor Azure quotas: Check deployment TPM/RPM limits
- Choose appropriate model:
text-embedding-3-smallfor cost-effectivenesstext-embedding-3-largefor better quality
- Deploy in same region: Reduce latency by deploying Azure resources nearby
- Use multiple deployments: Distribute load across deployments