Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Example: Using .NET Semantic Kernel to call Azure OpenAI

The example.js script dynamically loads the Microsoft.SemanticKernel .NET assembly and uses it to call Azure OpenAI to summarize some text. It is a direct JavaScript translation of the C# example code in the Semantic Kernel project readme.

To run this example, first set the following environment variables referencing your Azure OpenAI deployment:

  • OPENAI_ENDPOINT
  • OPENAI_DEPLOYMENT
  • OPENAI_KEY

Then run the following commands in sequence:

Command Explanation
dotnet pack ../.. Build Node API .NET packages.
dotnet build Install SemanticKernel nuget packages into the project and generate type definitions.
npm install Install node-api-dotnet npm package into the project.
node example.js Run example JS code that uses the above packages to call the Azure OpenAI service.