AzureOpenAIEmbeddings class, which wraps the Azure OpenAI service.
Installation
Embeddings require theopenai, azure-identity, numpy, and tiktoken libraries. See the Installation Guide for more information.
Embed text using Azure OpenAI embeddings
AzureOpenAIEmbeddings class, which wraps the Azure OpenAI service.
openai, azure-identity, numpy, and tiktoken libraries. See the Installation Guide for more information.
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"])
embeddings = AzureOpenAIEmbeddings(
azure_endpoint="https://my-resource.openai.azure.com/",
azure_api_key="my-key",
model="text-embedding-3-small",
deployment="embedding-deployment"
)
Was this page helpful?