Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.langchain.com/llms.txt

Use this file to discover all available pages before exploring further.

This page covers all LangChain integrations with Microsoft Azure and other Microsoft products.
Recommended: Azure OpenAIWe recommend using Azure OpenAI across chat models, LLMs, and embedding models. With the v1 API (Generally Available as of August 2025), you can use your Azure endpoint and API keys directly with the langchain-openai package to call any model deployed in Microsoft Foundry (including OpenAI, Llama, DeepSeek, Mistral, and Phi) through a single interface. You also get native support for Microsoft Entra ID authentication and access to the latest features including the Responses API and reasoning models. Get started here.Samples and tutorials:
Claude on AzureMicrosoft Foundry also offers access to all Anthropic Claude models, including Opus, Sonnet, and Haiku. Claude models are served through a dedicated Anthropic-native endpoint rather than the Azure OpenAI v1 API. Use langchain-anthropic pointed at your Foundry Anthropic endpoint.

Chat models

Microsoft offers three main options for accessing chat models through Azure:
  1. Azure OpenAI (recommended) — Access any model deployed in Microsoft Foundry (including OpenAI, Llama, DeepSeek, Mistral, and Phi) through a single interface, with enterprise features such as keyless authentication through Microsoft Entra ID, regional data residency, and private networking. Use ChatOpenAI on the v1 API, or AzureChatOpenAI for traditional deployments. Azure OpenAI also supports the Responses API, which gives you access to server-side tools like code interpreter, image generation, and file search directly from your chat model.
  2. Azure AI — Recommended for accessing tools, storage, and custom middleware from the broader Azure ecosystem alongside your chat model.
  3. Azure ML — Allows deployment and management of custom or fine-tuned open-source models with Azure Machine Learning.

Azure OpenAI

To get started with Azure OpenAI, create an Azure deployment and install the langchain-openai package:
pip install -U langchain-openai
On the v1 API, use ChatOpenAI directly against your Azure endpoint—no api_version required: For traditional Azure OpenAI API versions, use AzureChatOpenAI:
from langchain_openai import AzureChatOpenAI
See the Azure ChatOpenAI integration page for end-to-end setup, Entra ID authentication, tool calling, and reasoning examples.

Responses API

Azure OpenAI supports the Responses API, which provides stateful conversations, built-in tools (web search, file search, code interpreter), and structured reasoning summaries. ChatOpenAI automatically routes to the Responses API when you set the reasoning parameter, or you can opt in explicitly with use_responses_api=True: For a walkthrough of reasoning effort, reasoning summaries, and streaming with the Responses API, see the Azure ChatOpenAI integration page.

Azure AI

Azure AI Foundry is the broader Azure AI platform. The langchain-azure-ai package lets you bring Azure-native tools, storage, and custom middleware into your LangChain app, and exposes chat models deployed in Foundry through the AzureAIOpenAIApiChatModel class.
pip install -U langchain-azure-ai
See a usage example.

LLMs

Microsoft offers two main options for accessing LLMs through Azure:
  1. Azure OpenAI (recommended) — Access any model deployed in Microsoft Foundry (including OpenAI, Llama, DeepSeek, Mistral, and Phi) as a completion LLM with AzureOpenAI.
  2. Azure ML — Use custom or open-source models hosted on Azure Machine Learning online endpoints.

Azure OpenAI

See a usage example.
pip install -U langchain-openai

Embedding models

Microsoft offers two main options for accessing embedding models through Azure:
  1. Azure OpenAI (recommended) — Use embedding models deployed in Microsoft Foundry (including OpenAI text-embedding-3-small, text-embedding-3-large, and Cohere) with AzureOpenAIEmbeddings.
  2. Azure AI — Recommended for accessing tools, storage, and custom middleware from the broader Azure ecosystem alongside your embedding model.

Azure OpenAI

See a usage example.
pip install -U langchain-openai

Azure AI

pip install -U langchain-azure-ai
See a usage example.

Middleware

Azure AI Content Safety middleware

Azure AI Content Safety provides guardrails you can apply to LangChain agents through middleware. The langchain-azure-ai package currently exports middleware for text moderation, image moderation, prompt injection detection, protected material detection, and groundedness evaluation.
Install the middleware package:
pip install -U langchain-azure-ai
See the Microsoft Foundry middleware guide.
from langchain_azure_ai.agents.middleware import AzureContentModerationMiddleware

Document loaders

Azure Blob Storage

Azure Blob Storage is Microsoft’s object storage solution for the cloud. Blob Storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that doesn’t adhere to a particular data model or definition, such as text or binary data.
Azure Blob Storage is designed for:
  • Serving images or documents directly to a browser.
  • Storing files for distributed access.
  • Streaming video and audio.
  • Writing to log files.
  • Storing data for backup and restore, disaster recovery, and archiving.
  • Storing data for analysis by an on-premises or Azure-hosted service.
pip install langchain-azure-storage
See usage examples for the Azure Blob Storage Loader.
from langchain_azure_storage.document_loaders import AzureBlobStorageLoader

Memory

Azure cosmos DB chat message history

Azure Cosmos DB provides chat message history storage for conversational AI applications, enabling you to persist and retrieve conversation history with low latency and high availability.
pip install langchain-azure-cosmosdb
Configure your Azure Cosmos DB connection (sync or async, with access key or Microsoft Entra ID):
from langchain_azure_cosmosdb import CosmosDBChatMessageHistory

history = CosmosDBChatMessageHistory(
    cosmos_endpoint="https://<your-account>.documents.azure.com:443/",
    cosmos_database="<your-database>",
    cosmos_container="<your-container>",
    session_id="<session-id>",
    user_id="<user-id>",
    credential="<your-key-or-token-credential>",
    ttl=3600,  # optional: messages expire after 1 hour
)
history.prepare_cosmos()

history.add_user_message("Hello!")
history.add_ai_message("Hi there!")
For async usage, import AsyncCosmosDBChatMessageHistory from the same package.

Azure cosmos DB semantic cache

AzureCosmosDBNoSqlSemanticCache caches LLM responses in Azure Cosmos DB for NoSQL using vector similarity, returning cached results when a semantically similar prompt is seen again.
pip install langchain-azure-cosmosdb
from azure.cosmos import CosmosClient, PartitionKey
from langchain_core.globals import set_llm_cache
from langchain_azure_cosmosdb import AzureCosmosDBNoSqlSemanticCache

cosmos_client = CosmosClient("<endpoint>", "<key>")

cache = AzureCosmosDBNoSqlSemanticCache(
    cosmos_client=cosmos_client,
    embedding=embedding,
    vector_embedding_policy=vector_embedding_policy,
    indexing_policy=indexing_policy,
    cosmos_container_properties={"partition_key": PartitionKey(path="/id")},
    cosmos_database_properties={"id": "cache-db"},
    vector_search_fields={"text_field": "text", "embedding_field": "embedding"},
    database_name="cache-db",
    container_name="cache-container",
)

set_llm_cache(cache)
For async usage, import AsyncAzureCosmosDBNoSqlSemanticCache.

Vector stores

Azure cosmos DB

AI agents can rely on Azure Cosmos DB as a unified memory system solution, enjoying speed, scale, and simplicity. This service successfully enabled OpenAI’s ChatGPT service to scale dynamically with high reliability and low maintenance. Powered by an atom-record-sequence engine, it is the world’s first globally distributed NoSQL, relational, and vector database service that offers a serverless mode. Below are two available Azure Cosmos DB APIs that can provide vector store functionalities.

Azure cosmos DB for MongoDB (vCore)

Azure Cosmos DB for MongoDB vCore makes it easy to create a database with full native MongoDB support. You can apply your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB vCore account’s connection string. Use vector search in Azure Cosmos DB for MongoDB vCore to seamlessly integrate your AI-based applications with your data that’s stored in Azure Cosmos DB.
Installation and setup
See detailed configuration instructions. We need to install langchain-azure-ai and pymongo python packages.
pip install langchain-azure-ai pymongo
Deploy Azure cosmos DB on Microsoft Azure
Azure Cosmos DB for MongoDB vCore provides developers with a fully managed MongoDB-compatible database service for building modern applications with a familiar architecture. With Cosmos DB for MongoDB vCore, developers can enjoy the benefits of native Azure integrations, low total cost of ownership (TCO), and the familiar vCore architecture when migrating existing applications or building new ones. Sign Up for free to get started today. See a usage example.
from langchain_azure_ai.vectorstores import AzureCosmosDBMongoVCoreVectorSearch

Azure cosmos DB NoSQL

Azure Cosmos DB for NoSQL now offers vector indexing and search in preview. This feature is designed to handle high-dimensional vectors, enabling efficient and accurate vector search at any scale. You can now store vectors directly in the documents alongside your data. This means that each document in your database can contain not only traditional schema-free data, but also high-dimensional vectors as other properties of the documents. This colocation of data and vectors allows for efficient indexing and searching, as the vectors are stored in the same logical unit as the data they represent. This simplifies data management, AI application architectures, and the efficiency of vector-based operations.
Installation and setup
See detail configuration instructions. We need to install langchain-azure-cosmosdb and azure-cosmos python packages.
pip install langchain-azure-cosmosdb azure-cosmos
Deploy Azure cosmos DB on Microsoft Azure
Azure Cosmos DB offers a solution for modern apps and intelligent workloads by being very responsive with dynamic and elastic autoscale. It is available in every Azure region and can automatically replicate data closer to users. It has SLA guaranteed low-latency and high availability. Sign Up for free to get started today. See a usage example.
from langchain_azure_cosmosdb import AzureCosmosDBNoSqlVectorSearch

Azure Database for PostgreSQL

Azure Database for PostgreSQL - Flexible Server is a relational database service based on the open-source Postgres database engine. It’s a fully managed database-as-a-service that can handle mission-critical workloads with predictable performance, security, high availability, and dynamic scalability.
See set up instructions for Azure Database for PostgreSQL. Simply use the connection string from your Azure Portal. Since Azure Database for PostgreSQL is open-source Postgres, you can use the LangChain’s Postgres support to connect to Azure Database for PostgreSQL.

Azure SQL Database

Azure SQL Database is a robust service that combines scalability, security, and high availability, providing all the benefits of a modern database solution. It also provides a dedicated Vector data type & built-in functions that simplifies the storage and querying of vector embeddings directly within a relational database. This eliminates the need for separate vector databases and related integrations, increasing the security of your solutions while reducing the overall complexity.
By leveraging your current SQL Server databases for vector search, you can enhance data capabilities while minimizing expenses and avoiding the challenges of transitioning to new systems.
Installation and setup
See detail configuration instructions. We need to install the langchain-sqlserver python package.
!pip install langchain-sqlserver==0.1.1
Deploy Azure SQL DB on Microsoft Azure
Sign Up for free to get started today. See a usage example.
from langchain_sqlserver import SQLServer_VectorStore

Vector store

Azure Database for PostgreSQL

Azure Database for PostgreSQL - Flexible Server is a relational database service based on the open-source Postgres database engine. It’s a fully managed database-as-a-service that can handle mission-critical workloads with predictable performance, security, high availability, and dynamic scalability.
See set up instructions for Azure Database for PostgreSQL. You need to enable pgvector extension in your database to use Postgres as a vector store. Once you have the extension enabled, you can use the PGVector in LangChain to connect to Azure Database for PostgreSQL. See a usage example. Simply use the connection string from your Azure Portal.

Tools

Azure Container apps dynamic sessions

We need to get the POOL_MANAGEMENT_ENDPOINT environment variable from the Azure Container Apps service. See the Azure dynamic sessions setup instructions. We need to install a python package.
pip install langchain-azure-dynamic-sessions
See a usage example.
from langchain_azure_dynamic_sessions import SessionsPythonREPLTool