
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
azure-openai
Advanced tools
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.
To install this library, use the following command:
$ npm install azure-openai
The library needs to be configured with your Azure OpenAI's key, endpoint and deploymentId. you can obtain these credentials from Azure Portal. Please see the below screenshot:
To migrate from the official OpenAI model to the Azure OpenAI model, please follow these steps:
Install the library by running the following command:
$ npm install azure-openai
Update the import statement from "openai" to "azure-openai":
//import { Configuration, OpenAIApi } from "openai";
import { Configuration, OpenAIApi } from "azure-openai";
Pass the key and endpoint in the configuration:
this.openAiApi = new OpenAIApi(
new Configuration({
// this is the key of auzre openai resource
apiKey: {your-azure-openai-resource-key},
// this is the endpoint of auzre openai resource. Add this line to pass the base path
basePath: "https://${your-azure-openai-resource-name}.openai.azure.com/",
})
);
update deploymentId in model parameter when send request to Azure OpenAI:
const completion = await this.openAiApi.createCompletion({
// this is the deploymentId of auzre openai resource. pass the deployment id into model parameter
model: ${your-azure-openai-resource-deploymentId},
prompt: "Hello world",
......
});
optional, if you use stream = true. you may need to change response
// Azure OpenAI donot response delta data, so you need to change the response to text
// const delta = parsed.choices[0].delta.content;
const delta = parsed.choices[0].text;
Currently, only "gpt-3.5-turbo" API has been tested. Please feel free to submit your issues or pull requests to support other APIs.
FAQs
Node.js library for the Azure OpenAI API
The npm package azure-openai receives a total of 1,922 weekly downloads. As such, azure-openai popularity was classified as popular.
We found that azure-openai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.