本页还没有译文
本页 24 段还没译成Español,下面显示的是英文原文。Azure AI integrations
还没翻译译自英文(docs.langchain.com)本页 24 段都还没译
This page covers all LangChain integrations with Microsoft Azure and its related projects.
Integration packages for Azure AI, Dynamic Sessions, SQL Server are maintained in the langchain-azure repository.
Chat models
We recommend developers start with the (langchain-azure-ai) to access all the models available in Azure AI Foundry.
Azure AI chat completions
Access models like Azure OpenAI, DeepSeek R1, Cohere, Phi and Mistral using the AzureAIOpenAIApiChatModel class.
pip install -U langchain-azure-aiuv add langchain-azure-aiConfigure your endpoint. You can use a project endpoint with DefaultAzureCredential, or set an API key directly.
export AZURE_AI_PROJECT_ENDPOINT=your-project-endpointfrom langchain_azure_ai.chat_models import AzureAIOpenAIApiChatModel
from azure.identity import DefaultAzureCredential
llm = AzureAIOpenAIApiChatModel(
model="gpt-5.5",
credential=DefaultAzureCredential(),
)
llm.invoke('Tell me a joke and include some emojis')Embedding models
Azure AI model inference for embeddings
pip install -U langchain-azure-aiuv add langchain-azure-aiConfigure your endpoint. You can use a project endpoint with DefaultAzureCredential, or set an API key directly.
export AZURE_AI_PROJECT_ENDPOINT=your-project-endpointfrom langchain_azure_ai.embeddings import AzureAIOpenAIApiEmbeddingsModel
from azure.identity import DefaultAzureCredential
embed_model = AzureAIOpenAIApiEmbeddingsModel(
model="text-embedding-ada-002",
credential=DefaultAzureCredential(),
)Vector stores
Azure CosmosDB NoSQL vector search
Azure CosmosDB NoSQL is a fully managed, globally distributed, serverless document database for modern applications. It stores data in flexible JSON documents and uses a SQL-like query language. This provides high performance, low latency, and automatic, elastic scalability. It also features integrated vector search capabilities for AI workloads like generative AI and RAG. This allows you to store, index, and query vector embeddings alongside your operational data in the same database. You can combine vector similarity search with traditional keyword-based search for relevant results and choose from various indexing methods for optimal performance. This unified approach simplifies application architecture and ensures data consistency.
We need to install the langchain-azure-cosmosdb and azure-cosmos packages to use this vector store.
pip install -qU langchain-azure-cosmosdb azure-cosmosuv add langchain-azure-cosmosdb azure-cosmosfrom langchain_azure_cosmosdb import AzureCosmosDBNoSqlVectorSearch
vector_search = AzureCosmosDBNoSqlVectorSearch.from_documents(
documents=docs,
embedding=openai_embeddings,
cosmos_client=cosmos_client,
database_name=database_name,
container_name=container_name,
vector_embedding_policy=vector_embedding_policy,
full_text_policy=full_text_policy,
indexing_policy=indexing_policy,
cosmos_container_properties=cosmos_container_properties,
cosmos_database_properties={},
full_text_search_enabled=True,
)See a usage example.
Azure CosmosDB mongo vCore vector search
Azure CosmosDB Mongo vCore architecture 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) cluster's connection string.
We need to install the pymongo package to use this vector store.
pip install -qU pymongouv add pymongofrom langchain_azure_ai.vectorstores.azure_cosmos_db_mongo_vcore import (
AzureCosmosDBMongoVCoreVectorSearch,
)
vectorstore = AzureCosmosDBMongoVCoreVectorSearch.from_documents(
docs,
openai_embeddings,
collection=collection,
index_name=INDEX_NAME,
)See a usage example.