Share via

Azure OpenAI keep returing DeploymentNotFound error

大輝 小原 5 Reputation points
2023-06-06T11:20:00.3533333+00:00

I have deployed Azure OpenAI and can use the openAI playground, but when I try to access using the sample code below with javascript, it returns the following error. It's already been 4 days since I deployed it and I think there is something wrong. is there anyone having same issue? or does anyone knows how to fix it?

const {OpenAIClient, AzureKeyCredential} = require("@azure/openai");

const endpoint = "";
const azureApiKey = "";

const messages = [
  {role: "system", content: "You are a helpful assistant."},
  {role: "user", content: "Does Azure OpenAI support customer managed keys?"},
  {
    role: "assistant",
    content: "Yes, customer managed keys are supported by Azure OpenAI",
  },
  {role: "user", content: "Do other Azure Cognitive Services support this too"},
];

async function main() {
  console.log("== Chat Completions Sample ==");

  const client = new OpenAIClient(
    endpoint,
    new AzureKeyCredential(azureApiKey),
  );
  const deploymentId = "gpt-35-turbo";
  const result = await client.getChatCompletions(deploymentId, messages);

  for (const choice of result.choices) {
    console.log(choice.message);
  }
}

main().catch((err) => {
  console.error("The sample encountered an error:", err);
});

module.exports = {main};

  error: {
    code: 'DeploymentNotFound',
    message: 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'
  }
Azure OpenAI in Foundry Models

1 answer

Sort by: Most helpful
  1. Harris Bin Khalid 0 Reputation points
    2023-06-08T09:28:08.1033333+00:00

    Make sure that the variable deploymentId is equal to the name of the deployment on azure and not the model name. deployment1

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.