Azure OpenAI is a Microsoft Azure service that provides powerful language models from OpenAI. This will help you getting started withDocumentation Index
Fetch the complete documentation index at: https://nvd-54.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
AzureChatOpenAI chat models. For detailed documentation of all AzureChatOpenAI features and configurations head to the API reference.
概述
集成详情
| Class | Package | Serializable | PY support | Downloads | Version |
|---|---|---|---|---|---|
AzureChatOpenAI | @langchain/openai | ✅ | ✅ |
模型功能
请参阅下表标题中的链接,了解如何使用特定功能。| Tool calling | Structured output | Image input | Audio input | Video input | Token-level streaming | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ |
设置
Azure OpenAI is a cloud service to help you quickly develop generative AI experiences with a diverse set of prebuilt and curated models from OpenAI, Meta and beyond. LangChain.js supports integration with Azure OpenAI using the new Azure integration in the OpenAI SDK. You can learn more about Azure OpenAI and its difference with the OpenAI API on this page.凭证
If you don’t have an Azure account, you can create a free account to get started. You’ll also need to have an Azure OpenAI instance deployed. You can deploy a version on Azure Portal following this guide. Once you have your instance running, make sure you have the name of your instance and key. You can find the key in the Azure Portal, under the “Keys and Endpoint” section of your instance. Then, if using Node.js, you can set your credentials as environment variables:安装
LangChain 的 AzureChatOpenAI 集成位于@langchain/openai 包中:
实例化
现在我们可以实例化模型对象并生成聊天补全:调用
Using Azure Managed identity
If you’re using Azure Managed Identity, you can configure the credentials like this:Using a different domain
If your instance is hosted under a domain other than the defaultopenai.azure.com, you’ll need to use the alternate AZURE_OPENAI_BASE_PATH environment variable.
For example, here’s how you would connect to the domain https://westeurope.api.microsoft.com/openai/deployments/{DEPLOYMENT_NAME}:
自定义请求头
You can specify custom headers by passing in aconfiguration field:
configuration field also accepts other ClientOptions parameters accepted by the official SDK.
Note: The specific header api-key currently cannot be overridden in this manner and will pass through the value from azureOpenAIApiKey.
Migration from Azure OpenAI SDK
If you are using the deprecated Azure OpenAI SDK with the@langchain/azure-openai package, you can update your code to use the new Azure integration following these steps:
- Install the new
@langchain/openaipackage and remove the previous@langchain/azure-openaipackage:
-
Update your imports to use the new
AzureChatOpenAIclass from the@langchain/openaipackage: -
Update your code to use the new
AzureChatOpenAIclass and pass the required parameters:Notice that the constructor now requires theazureOpenAIApiInstanceNameparameter instead of theazureOpenAIEndpointparameter, and adds theazureOpenAIApiVersionparameter to specify the API version.-
If you were using Azure Managed Identity, you now need to use the
azureADTokenProviderparameter to the constructor instead ofcredentials, see the Azure Managed Identity section for more details. -
If you were using environment variables, you now have to set the
AZURE_OPENAI_API_INSTANCE_NAMEenvironment variable instead ofAZURE_OPENAI_API_ENDPOINT, and add theAZURE_OPENAI_API_VERSIONenvironment variable to specify the API version.
-
If you were using Azure Managed Identity, you now need to use the
API 参考
有关所有AzureChatOpenAI 功能和配置的详细文档,请前往 API 参考。
将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

