{"id":5302,"library":"llama-index-embeddings-azure-openai","title":"LlamaIndex Embeddings Azure OpenAI","description":"The `llama-index-embeddings-azure-openai` library provides an integration for LlamaIndex to leverage Azure OpenAI's embedding models. It allows users to generate sophisticated numerical representations of text for use within LlamaIndex applications, particularly for Retrieval-Augmented Generation (RAG) workflows. This library is an actively developed component of the broader LlamaIndex ecosystem, with updates typically aligning with the main LlamaIndex project's release cycle.","status":"active","version":"0.5.2","language":"en","source_language":"en","source_url":"https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/embeddings/llama-index-embeddings-azure-openai","tags":["embeddings","Azure OpenAI","LlamaIndex","LLM","RAG","AI"],"install":[{"cmd":"pip install llama-index-embeddings-azure-openai","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"Core framework dependency for all LlamaIndex integrations.","package":"llama-index-core","optional":false},{"reason":"Required for interacting with Azure OpenAI service APIs.","package":"openai","optional":false},{"reason":"Serves as the base class for AzureOpenAIEmbedding, providing shared functionality.","package":"llama-index-embeddings-openai","optional":false}],"imports":[{"symbol":"AzureOpenAIEmbedding","correct":"from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding"}],"quickstart":{"code":"import os\nfrom llama_index.embeddings.azure_openai import AzureOpenAIEmbedding\nfrom llama_index.core import Settings\n\n# Ensure environment variables are set for Azure OpenAI\n# AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_VERSION, AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME\n\napi_key = os.environ.get('AZURE_OPENAI_API_KEY', 'your-api-key')\nazure_endpoint = os.environ.get('AZURE_OPENAI_ENDPOINT', 'https://your-resource-name.openai.azure.com/')\napi_version = os.environ.get('AZURE_OPENAI_API_VERSION', '2023-07-01-preview')\ndeployment_name = os.environ.get('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME', 'your-embedding-deployment-name')\nmodel_name = os.environ.get('AZURE_OPENAI_EMBEDDING_MODEL_NAME', 'text-embedding-ada-002') # The actual model name you deployed\n\nif not all([api_key, azure_endpoint, api_version, deployment_name]):\n    raise ValueError(\"Please set all required Azure OpenAI environment variables or provide them directly.\")\n\nembed_model = AzureOpenAIEmbedding(\n    model=model_name,\n    deployment_name=deployment_name,\n    api_key=api_key,\n    azure_endpoint=azure_endpoint,\n    api_version=api_version,\n)\n\n# Set the embedding model globally for LlamaIndex\nSettings.embed_model = embed_model\n\n# Example usage: get an embedding\ntext_to_embed = \"This is a test sentence for Azure OpenAI embeddings.\"\nembeddings = embed_model.get_text_embedding(text_to_embed)\n\nprint(f\"Embedding generated with length: {len(embeddings)}\")\n# print(embeddings) # Uncomment to see the full embedding vector","lang":"python","description":"This quickstart demonstrates how to initialize `AzureOpenAIEmbedding` and set it as the global embedding model for LlamaIndex. It fetches necessary Azure OpenAI credentials from environment variables, which is the recommended secure practice. Replace placeholder values with your actual Azure OpenAI details."},"warnings":[{"fix":"Ensure `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_API_VERSION`, and `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variables are set, or pass these parameters directly to the `AzureOpenAIEmbedding` constructor.","message":"Azure OpenAI requires explicit configuration of `api_base` (or `azure_endpoint`), `api_key`, `api_version`, and a `deployment_name` (often referred to as 'engine' in older docs). These are distinct from standard OpenAI API calls.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consult Azure OpenAI documentation for model availability by region. Configure `AzureOpenAIEmbedding` and `AzureOpenAI` (for LLMs) with distinct `azure_endpoint` values if their respective deployments are in different regions.","message":"Due to regional variations in Azure OpenAI model availability, you might need to deploy embedding models and chat completion models in different Azure regions, requiring separate endpoint configurations.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always check the `pyproject.toml` or `setup.py` of `llama-index-embeddings-azure-openai` for its exact `llama-index-core` dependency range. When encountering conflicts, try upgrading or downgrading `llama-index-core` or the `azure-openai` integration package to a compatible version. Using `pip install --upgrade llama-index llama-index-embeddings-azure-openai` may help resolve to compatible versions, but manual intervention might be needed for specific scenarios.","message":"Version compatibility issues can arise between specific versions of `llama-index-embeddings-azure-openai` and `llama-index-core`, leading to dependency resolution errors. For example, some `llama-index-llms-azure-openai` versions depended on `llama-index-core<0.13`, conflicting with newer `llama-index` requirements.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"For versions 0.5.0+, utilize the `azure_ad_token_provider` and `use_azure_ad=True` parameters in `AzureOpenAIEmbedding`. Verify that `AZURE_OPENAI_API_KEY` is not set if relying solely on Azure AD for authentication, unless explicitly required by your specific Azure setup.","message":"When using Azure AD for authentication, older versions (e.g., 0.1.9) had a bug where `api_key` was still erroneously required. While likely fixed in newer versions (0.5.2+ includes `azure_ad_token_provider` parameter), ensure proper configuration if using Azure AD.","severity":"gotcha","affected_versions":"<0.5.0"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}