-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Checked other resources
- This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
- I added a very descriptive title to this issue.
- I searched the LangChain.js documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain.js rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
The config reads from the env files but if something is not provided it sets default values.
const model = new AzureChatOpenAI({
apiKey: config.azure.apiKey,
azureOpenAIApiDeploymentName: "gpt-4o",
azureOpenAIApiInstanceName: config.azure.instanceName,
azureOpenAIApiVersion: config.azure.openai.apiVersion,
cache: true,
model: "gpt-4o",
temperature: config.openAi.temperature,
});
await model.invoke("Hi");
Error Message and Stack Trace (if applicable)
Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.
Error: Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.
at new AzureOpenAI (.../node_modules/openai/src/azure.ts:82:13)
at ChatOpenAICompletions._getClientOptions (.../node_modules/@langchain/openai/dist/azure/chat_models.cjs:570:27)
at ChatOpenAICompletions.completionWithRetry (.../node_modules/@langchain/openai/dist/chat_models.cjs:1916:36)
at ChatOpenAICompletions._streamResponseChunks (.../node_modules/@langchain/openai/dist/chat_models.cjs:1827:43)
at _streamResponseChunks.next (<anonymous>)
at AzureChatOpenAI._streamResponseChunks (.../node_modules/@langchain/openai/dist/chat_models.cjs:2678:33)
at _streamResponseChunks.next (<anonymous>)
at AzureChatOpenAI._streamIterator (.../node_modules/@langchain/core/dist/language_models/chat_models.cjs:127:34)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async AzureChatOpenAI.transform (.../node_modules/@langchain/core/dist/runnables/base.cjs:410:9)
Description
It appears that AzureChatOpenAI doesn't respect what we're setting in the constructor parameters, but instead just tries to read from the env files directly (which doesn't have everything set because of the default values).
System Info
Node 24
MacOS
@langchain/[email protected] | MIT | deps: 3 | versions: 110
OpenAI integrations for LangChain.js
https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-openai/
keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores
dependencies (3):
- js-tiktoken: ^1.0.12
- openai: ^5.3.0
- zod: ^3.25.32
dist
.tarball: https://registry.npmjs.org/@langchain/openai/-/openai-0.6.2.tgz
.shasum: fb68fa7305ef419e772a56c29146810c0923513d
.integrity: sha512-OjdSfGENdz4tR9TPN4KTat7vJIE6cgt7vT0z69qU1J1aHCs9MyNwqdaQFF++LVlZAae9aTpyCyqeODyge42oKw==
.unpackedSize: 0.44 MB
dist-tags:
next: 0.5.3-dev.0
latest: 0.6.2
maintainers:
- hwchase17 [email protected]
- jacoblee93 [email protected]
- basproul [email protected]
- eric_langchain [email protected]
- andrewnguonly [email protected]
- nfcampos [email protected]
- davidduong [email protected]
- maddyadams [email protected]
- sam_noyes [email protected]
- hntrl [email protected]
Published: 2025-07-17T16:36:26.471Z