Registry / llm-agents / langchain-azure-ai

langchain-azure-ai

JSON →
library1.2.6pypypiunverified

langchain-azure-ai is an integration package that provides first-class support for Azure AI Foundry capabilities within the LangChain and LangGraph ecosystems. It currently ships at version 1.2.2 and maintains an active release cadence with frequent updates and patches.

pip install -U langchain-azure-ai
INSTALL
IMPORT
SIG · LANGCHAIN-AZURE-AI
L
langchain-azure-ai
llm-agentspythonv1.2.6
Install
19.4s avg
Import
6046ms
Disk
244MB
Pass rate
6/ 10
Env Coverage6 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✕ build_error
py 3.11
✓ —
✓ 18.89s
py 3.12
✕ build_error
✕ build_error
py 3.13
✓ —
✓ 15.48s
py 3.9
✓ —
✓ 23.83s
244MB installed
● package 244MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AzureAIOpenAIApiChatModel
from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel
AzureAIChatCompletionsModel
from langchain_azure_ai.chat_models.inference import AzureAIChatCompletionsModel
from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel
This class is deprecated in favor of AzureAIOpenAIApiChatModel for OpenAI-compatible APIs. If still needed, it requires the [v1] extra and is now under `langchain_azure_ai.chat_models.inference` namespace.
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Recommended for authentication when using project endpoints with Microsoft Entra ID.

This quickstart demonstrates how to initialize and use the `AzureAIOpenAIApiChatModel` for chat completions. It showcases both API key and Azure Entra ID (via `DefaultAzureCredential`) authentication methods, preferring environment variables for configuration.

import os from azure.identity import DefaultAzureCredential from langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel from langchain_core.messages import HumanMessage, SystemMessage # Ensure these environment variables are set # os.environ["AZURE_AI_PROJECT_ENDPOINT"] = "https://{your-resource-name}.services.ai.azure.com" # os.environ["AZURE_AI_API_KEY"] = "your-api-key" # Use DefaultAzureCredential for Entra ID authentication with project_endpoint # For API key authentication, pass 'credential="your-api-key"' directly credential = os.environ.get('AZURE_AI_API_KEY', DefaultAzureCredential()) model = AzureAIOpenAIApiChatModel( endpoint=os.environ.get('AZURE_AI_PROJECT_ENDPOINT', 'https://your-resource-name.services.ai.azure.com/openai/v1'), credential=credential, model="gpt-4o" # Or your deployed model name like 'gpt-4o' ) messages = [ SystemMessage(content="You are a helpful translator. Translate the following from English into Italian."), HumanMessage(content="I love programming.") ] response = model.invoke(messages) print(response.content)
Debug
Known issues
breakingThe `AzureAIChatCompletionsModel` and `AzureAIEmbeddingsModel` classes (using Azure AI Inference SDK) have been deprecated in favor of OpenAI-compatible APIs. They now reside under the `inference` sub-namespace and require the `langchain-azure-ai[v1]` extra.
fix
Migrate to `AzureAIOpenAIApiChatModel` and `AzureAIOpenAIApiEmbeddingsModel` for new development. If using deprecated classes, install `langchain-azure-ai[v1]` and update imports to `from langchain_azure_ai.chat_models.inference import AzureAIChatCompletionsModel`.
affects: >=1.1.0
breakingThe `project_connection_string` parameter for creating `AzureAIEmbeddingsModel` and `AzureAIChatCompletionsModel` is no longer supported. Use `project_endpoint` instead.
fix
Replace `project_connection_string` with `project_endpoint` when initializing models.
affects: >=0.1.6
deprecatedThe `AzureAIInferenceTracer` class has been removed. It is replaced by `AzureAIOpenTelemetryTracer` for better OpenTelemetry support and new GenAI semantic conventions.
fix
Update tracing implementations to use `AzureAIOpenTelemetryTracer`. Ensure `langchain-azure-ai[opentelemetry]` is installed.
affects: >=0.1.6
deprecatedCreating agents using Foundry Agents V1 (e.g., `AgentServiceFactory`) has been deprecated in favor of V2 implementation.
fix
Update agent creation logic to use the V2 implementation. The `AgentServiceFactory` for V1 now requires the `langchain-azure-ai[v1]` extra.
affects: >=1.1.0
gotchaUsing `init_chat_model("azure_ai:...")` convenience method requires `langchain>=1.2.13` for full functionality, especially streaming implementations.
fix
Ensure your `langchain` package is updated to at least version `1.2.13` to leverage `init_chat_model` effectively. Otherwise, configure clients directly.
affects: <1.2.13
gotchaAuthentication with a `project_endpoint` (set via `AZURE_AI_PROJECT_ENDPOINT` environment variable) strictly requires Microsoft Entra ID for authentication and the 'Azure AI User' role on the project.
fix
Ensure your environment is configured for Azure CLI login (`az login`) or use `DefaultAzureCredential`. Verify that the assigned identity has the 'Azure AI User' role on the Foundry project.
affects: All
Upgrade
Version history
1.2.6latest on PyPI · released Jun 12, 2026
Audit
Dependencies
langchain-corerequiredCore LangChain abstractions and streaming implementations require a compatible version (>=1.2 for streaming).
azure-identityrequiredRequired for authentication with Microsoft Entra ID and DefaultAzureCredential.
azure-ai-projectsoptionalRequired for creating models directly from your AI project's connection string.
langchainrequiredThe core LangChain library for building chains, agents, and retrieval strategies.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
langchain-azure-ai — pip install langchain-azure-ai · libregistry