1openwindow / azure-openai-node

This is a fork of the official OpenAI Node.js library that has been adapted to support the Azure OpenAI API. The objective of this library is to minimize the changes required to migrate from the official OpenAI library to Azure OpenAI or revert back to OpenAI.
https://www.npmjs.com/package/azure-openai
MIT License
79 stars 12 forks source link

running into issues with the createCompletionAPI #8

Closed sfc-gh-rchao closed 1 year ago

sfc-gh-rchao commented 1 year ago
    const openAi = new OpenAIApi(
      new Configuration({
        apiKey: azureOpenAiKey,
        // add azure info into configuration
        azure: {
          apiKey: azureOpenAiKey,
          endpoint: azureBaseUrl,
          deploymentName: azureDeploymentName,
        },
      }),
    );
    try {
      const completion = await openAi.createCompletion({
        model: completionModel,
        prompt,
        max_tokens: 256,
        n: 1,
        temperature: 0,
      });
      const message = completion.data.choices[0].text;
      return message;
    } catch (e) {
      console.log({ e });
    }

get the following error

    response: {
      status: 400,
      statusText: 'Bad Request',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: [Object]
    },
    isAxiosError: true,

any ideas what might be causing this?

sfc-gh-rchao commented 1 year ago

nevermind. it seems i left the deploymentName as the wrong env var.