Sitemap
.Net Programming

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

Member-only story

Unlocking OpenAI Integration with .NET 8

3 min readMar 5, 2024

--

Photo by Andrew Neel on Unsplash

In this guide, you’ll discover how to make the most of the .NET Aspire Azure AI OpenAI client.

To begin, you’ll need an Azure subscription, which can be created for free, and an Azure AI OpenAI or OpenAI account. Here’s how to get started with the .NET Aspire Azure AI OpenAI component:

Installation

Start by installing the Aspire.Azure.AI.OpenAI NuGet package. You can do this using the .NET CLI or PackageReference.

dotnet add package Aspire.Azure.AI.OpenAI --prerelease

Example Usage

In your project’s Program.cs file, you’ll register an OpenAIClient using an extension method. This method requires a connection name parameter.

builder.AddAzureOpenAI("openAiConnectionName");

This snippet adds an OpenAIClient to the DI container. The parameter openAiConnectionName refers to the connection string in the configuration. You can then access…

--

--

.Net Programming
.Net Programming

Published in .Net Programming

Explore the .Net with the latest in C# from basic to advanced, including .Net versions 9, 8, 6, 5, Core 3.1, .Net Framework, ASP.NET Core, MVC, design patterns, OOPS, and SOLID principles. Get top tutorials, best practices, and hands-on code examples on GitHub.

Sukhpinder Singh | C# .Net
Sukhpinder Singh | C# .Net

Written by Sukhpinder Singh | C# .Net

C# .Net developer 👨‍💻 who's 100% convinced my bugs are funnier than yours. 🐛💥 #BugLife Pubs: https://medium.com/c-sharp-programming