Skip to main content

Setup & Prerequisites

There are a few prerequisites to getting started with integrating LLMs into your C# application:

  • LLM API Key - To generate messages using an LLM, you will need to have an API Key for the LLM you are using.
  • NuGet Package - Install the Microsoft Teams AI library:
    dotnet add package Microsoft.Teams.AI
  • In your C# application, you should include your keys securely using appsettings.json or environment variables
myapp/
β”œβ”€β”€ myapp.sln # Solution file
β”œβ”€β”€ myapp.slnlaunch.user # Launch configuration
└── myapp/ # Main project directory
β”œβ”€β”€ .editorconfig # Editor configuration
β”œβ”€β”€ appsettings.json # Application configuration
β”œβ”€β”€ appsettings.Development.json # Development configuration
β”œβ”€β”€ myapp.csproj # Project file
β”œβ”€β”€ MainController.cs # Main controller
β”œβ”€β”€ Program.cs # Application entry point
└── Properties/
└── launchSettings.json # Launch settings

Azure OpenAI​

You will need to deploy a model in Azure OpenAI. Here is a guide on how to do this.

Once you have deployed a model, configure your application using either appsettings.json or environment variables:

Environment Variables

AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_MODEL_DEPLOYMENT_NAME=your-azure-openai-model
AZURE_OPENAI_ENDPOINT=your-azure-openai-endpoint
AZURE_OPENAI_API_VERSION=your-azure-openai-api-version
info

The AZURE_OPENAI_API_VERSION is different from the model version. This is a common point of confusion. Look for the API Version here

OpenAI​

You will need to create an OpenAI account and get an API key. Here is a guide on how to do this.

Once you have your API key, configure your application:

Environment Variables

OPENAI_API_KEY=sk-your-openai-api-key