Skip to main content

Overview

The AzureOpenAIEmbedderClient provides embeddings using OpenAI models hosted on Azure, supporting both the native Azure OpenAI SDK and OpenAI’s v1 API compatibility endpoint.

Installation

The OpenAI SDK (which includes Azure support) is included by default.

Basic Usage

Constructor

AsyncAzureOpenAI | AsyncOpenAI
required
Pre-configured Azure OpenAI client. Must be either:
  • AsyncAzureOpenAI for native Azure SDK
  • AsyncOpenAI with 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 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.
Parameters:
  • input_data (str | list[str] | Any): Input to embed
Returns: 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.
Parameters:
  • input_data_list (list[str]): List of texts to embed
Returns: list[list[float]] - List of embedding vectors

Input Type Handling

The embedder handles different input types:
Implementation:

Error Handling

Common errors:
  • 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

Unlike OpenAIEmbedder, this client does NOT truncate dimensions:
Or wrap in a custom class:

Batch Processing

Efficiently process multiple texts:
Implementation:

Example: Document Embedding

Use with Graphiti

Comparison with OpenAIEmbedder

Performance Tips

  1. Use batch processing: Always prefer create_batch() for multiple inputs
  2. Monitor Azure quotas: Check deployment TPM/RPM limits
  3. Choose appropriate model:
    • text-embedding-3-small for cost-effectiveness
    • text-embedding-3-large for better quality
  4. Deploy in same region: Reduce latency by deploying Azure resources nearby
  5. Use multiple deployments: Distribute load across deployments

Troubleshooting

Authentication Errors

Deployment Not Found

Rate Limiting