-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure OpenAI Deployment Not Found #5754
Comments
Hello, @ranjiitk121! I'm here to assist you with any bugs, questions, or contributions. To resolve the "Azure OpenAI API deployment name not found" error when using the const { AzureChatOpenAI } = require('@langchain/openai');
const model = new AzureChatOpenAI({
temperature: 0.9,
azureOpenAIApiKey: 'our-key', // In Node.js defaults to process.env.AZURE_OPENAI_API_KEY
azureOpenAIApiInstanceName: 'instance-name', // In Node.js defaults to process.env.AZURE_OPENAI_API_INSTANCE_NAME
azureOpenAIApiDeploymentName: 'deployment-name', // In Node.js defaults to process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME
azureOpenAIApiVersion: '2024-04-01-preview', // In Node.js defaults to process.env.AZURE_OPENAI_API_VERSION
azureOpenAIBasePath: 'https://custom-url-open-ai.openai.azure.com', // Ensure this is the correct base path
});
model
.invoke('What would be a good company name for a company that makes colorful socks?')
.then((res) => {
console.log(res);
})
.catch((err) => console.log('error', err)); Make sure that the If you continue to face issues, verify that all required environment variables are correctly set and match the details of your Azure OpenAI service. Here is a more detailed example of the initialization: const { AzureChatOpenAI } = require('@langchain/openai');
const model = new AzureChatOpenAI({
temperature: 0.9,
azureOpenAIApiKey: process.env.AZURE_OPENAI_API_KEY,
azureOpenAIApiInstanceName: process.env.AZURE_OPENAI_API_INSTANCE_NAME,
azureOpenAIApiDeploymentName: process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME,
azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION,
azureOpenAIBasePath: process.env.AZURE_OPENAI_BASE_PATH,
});
model
.invoke('What would be a good company name for a company that makes colorful socks?')
.then((res) => {
console.log(res);
})
.catch((err) => console.log('error', err)); Ensure that the environment variables |
Ensure that the environment variables AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_INSTANCE_NAME, AZURE_OPENAI_API_DEPLOYMENT_NAME, AZURE_OPENAI_API_VERSION, and AZURE_OPENAI_BASE_PATH are correctly set in your environment. |
Does this help? |
Yes, the values are picked from .env itself so it is nesscary to set .env variable |
Not really.
Error:
|
We cannot use env var (values are stored in some secret manager). I am following langchain doc, and it's stated that if a value is not passed, it would default to certain env. However, in my case, I am passing values.
I can make call successfully by using openai package.
ENV file
|
I encountered the same issue and realized that I had mistakenly confused AZURE_OPENAI_BASE_PATH with AZURE_OPENAI_API_ENDPOINT. Adding openai/deployments to the AZURE_OPENAI_API_ENDPOINT resolved the problem. It would have been helpful if the path of the missing resource was logged, as this could have sped up the troubleshooting process. Here’s the corrected code:
|
Yeah that's a good idea, will look into it |
did you manage to solve it? I'm currently having the same issue |
@jacoblee93 Still encountering this error -
Alternatively I tried not including the base path, and then including it as - I'm on Here's a public trace on langsmith. @ranjiitk121 Did you guys ever get around to using azure via langchain? |
Check this out maybe it will help you |
I faced this when i used OpenAI and AzureOpenAI both, since env first reads Azure key related environment variable, then OpenAI key. const llm = new AzureChatOpenAI({ same error occured AzureOpenAI deployment not found-> it is asking to provide azure related credential in openai configuration too, which is not needed. any way to solve this??? |
You should bump to |
Checked other resources
Example Code
Below codes results in
Azure OpenAI API deployment name not found
error.Below works fine with same values (using open ai package).
Error Message and Stack Trace (if applicable)
Error: Azure OpenAI API deployment name not found
Description
I am following the guide to use Azure OpenAI via langchainjs but I keep getting " Azure OpenAI API deployment name not found" error. I know that our base URL for Azure is different, and I specify the correct one. Other values are also correct. I am certain of it as I run the other snippet, which is using openai package to connect to AzureOpenAi, and it works.
Please check the examples.
System Info
LangchainJs Version: "^0.1.37"
Npm Version:1 0.5.0
Node: 18.20.2
Platform: M2 MacOS
The text was updated successfully, but these errors were encountered: