{"id":5303,"library":"llama-index-llms-azure-openai","title":"LlamaIndex Azure OpenAI LLM Integration","description":"This integration package allows LlamaIndex to utilize Azure OpenAI's Large Language Model (LLM) services. It provides a robust way to connect to and interact with models like GPT-3.5 and GPT-4 deployed on Azure, leveraging LlamaIndex's indexing and querying capabilities. The current version is 0.5.3, with its release cadence tied to updates in the core LlamaIndex library and Azure OpenAI API changes.","status":"active","version":"0.5.3","language":"en","source_language":"en","source_url":"https://github.com/run-llama/llama_index/tree/main/llama-index-integrations/llms/llama-index-llms-azure-openai","tags":["LLM","LlamaIndex","Azure","OpenAI","Integration"],"install":[{"cmd":"pip install llama-index-llms-azure-openai","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"Required by all LlamaIndex integrations for core functionality.","package":"llama-index-core"},{"reason":"The underlying Python client for interacting with the OpenAI API, including Azure OpenAI.","package":"openai"}],"imports":[{"symbol":"AzureOpenAI","correct":"from llama_index.llms.azure_openai import AzureOpenAI"}],"quickstart":{"code":"import os\nfrom llama_index.llms.azure_openai import AzureOpenAI\nfrom llama_index.core import Settings\n\n# Ensure these environment variables are set:\n# AZURE_OPENAI_API_KEY\n# AZURE_OPENAI_ENDPOINT (e.g., 'https://YOUR_RESOURCE_NAME.openai.azure.com/')\n# AZURE_OPENAI_API_VERSION (e.g., '2023-05-15' or '2024-02-15-preview')\n# AZURE_OPENAI_LLM_DEPLOYMENT_NAME (your deployment name, e.g., 'gpt-35-turbo-deployment')\n\nazure_openai_api_key = os.environ.get('AZURE_OPENAI_API_KEY', 'YOUR_AZURE_OPENAI_API_KEY')\nazure_openai_endpoint = os.environ.get('AZURE_OPENAI_ENDPOINT', 'https://example.openai.azure.com/')\nazure_openai_api_version = os.environ.get('AZURE_OPENAI_API_VERSION', '2023-05-15')\nazure_llm_deployment_name = os.environ.get('AZURE_OPENAI_LLM_DEPLOYMENT_NAME', 'your-gpt-35-turbo-deployment')\n\nllm = AzureOpenAI(\n    model=azure_llm_deployment_name, # This must be your Azure deployment name\n    api_key=azure_openai_api_key,\n    azure_endpoint=azure_openai_endpoint,\n    api_version=azure_openai_api_version,\n    temperature=0.7,\n)\n\n# Optionally set as default LLM for LlamaIndex global settings\nSettings.llm = llm\n\n# Make a completion call\nresponse = llm.complete(\"Tell me a short story about a brave knight.\")\nprint(response.text)","lang":"python","description":"This quickstart demonstrates how to initialize the `AzureOpenAI` LLM and use it for a simple completion task. It highlights the required environment variables for Azure OpenAI authentication and configuration, as well as how to set the LLM globally using `Settings` (LlamaIndex v0.10.0+ pattern) or directly interact with the instance."},"warnings":[{"fix":"Migrate from `ServiceContext(llm=...)` to `from llama_index.core import Settings; Settings.llm = AzureOpenAI(...)`. For specific components, pass the `llm` instance directly.","message":"LlamaIndex core versions 0.10.0 and above deprecate `ServiceContext` for global configuration. LLMs should now be configured either directly on `Settings.llm` or passed explicitly to constructors.","severity":"breaking","affected_versions":"llama-index-core>=0.10.0"},{"fix":"Ensure `model` is set to the exact deployment name as configured in your Azure OpenAI Studio. Also verify `azure_endpoint` is the correct resource endpoint URL and `api_version` matches your deployment's supported version.","message":"The `model` parameter in `AzureOpenAI` refers to your *Azure deployment name*, not the base OpenAI model name (e.g., 'gpt-35-turbo-deployment', not 'gpt-3.5-turbo'). Incorrectly setting this will lead to errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use a current and valid `api_version` supported by your Azure OpenAI deployment. Consult Azure's documentation for the latest recommended stable API version. Commonly '2023-05-15' or newer 'preview' versions are used.","message":"Azure OpenAI API versions (`api_version`) are date-based and specific (e.g., '2023-05-15'). Using an invalid, unsupported, or outdated version can cause API calls to fail or return unexpected results.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}