Skip to main content
Embeddings are handled by the AzureOpenAIEmbeddings class, which wraps the Azure OpenAI service.

Installation

Embeddings require the openai, azure-identity, numpy, and tiktoken libraries. See the Installation Guide for more information.

Usage

from chonkie import AzureOpenAIEmbeddings

# Initialize Azure OpenAI embeddings
embeddings = AzureOpenAIEmbeddings(
	azure_endpoint="https://<your-resource>.openai.azure.com/",
	azure_api_key="<your-api-key>",
	model="text-embedding-3-small",  # or other supported model
	deployment="<your-deployment-name>"
)

# Single embedding
emb = embeddings.embed("your text here")

# Batch embedding
embs = embeddings.embed_batch(["text1", "text2"])

Example

embeddings = AzureOpenAIEmbeddings(
	azure_endpoint="https://my-resource.openai.azure.com/",
	azure_api_key="my-key",
	model="text-embedding-3-small",
	deployment="embedding-deployment"
)
I