Skip to main content
本指南将帮助您开始使用 AzureAIOpenAIApiChatModel 聊天模型. The AzureAIOpenAIApiChatModel class uses the OpenAI-compatible API available in Azure AI Foundry. AI Foundry has several 聊天模型, including AzureOpenAI, Cohere, Llama, Phi-3/4, and DeepSeek-R1, among others. You can find information about their latest models and their costs, context windows, and supported input types in the Azure docs.

概述

集成详情

模型功能

设置

要访问 AzureAIOpenAIApiChatModel models, you’ll need to create an Azure account, get an API key, and install the langchain-azure-ai 集成包。

凭证

Head to the Azure docs to see how to create your deployment 并生成 API 密钥。 Once your model is deployed, you click the ‘get endpoint’ button in AI Foundry. This will show you your endpoint and api key. 完成后,设置 environment variables:
If you want to get automated tracing of your model calls, you can also set your LangSmith API key by uncommenting below:

安装

LangChain 的 AzureAIOpenAIApiChatModel 集成位于 langchain-azure-ai 包中:

实例化

现在我们可以实例化模型对象并生成聊天补全:

调用