Skip to content

rafsanulhasan/Standard.AI.OpenAI

 
 

Repository files navigation

OpenAI.NET


.NET The Standard - COMPLIANT The Standard Community

Introduction

OpenAI.NET is a Standard-Compliant .NET library built on top of OpenAI API RESTful endpoints to enable software engineers to develop AI-Powered solutions in .NET.

Standard-Compliance

This library was built according to The Standard. The library follows engineering principles, patterns and tooling as recommended by The Standard.

This library is also a community effort which involved many nights of pair-programming, test-driven development and in-depth exploration research and design discussions.

How to use this library?

In order to use this library there are prerequists that you must complete before you can write your first AI-Powered C#.NET program. These steps are as follows:

OpenAI Account

You must create an OpenAI account with the following link: https://platform.openai.com/signup

API Keys

Once you've created an OpenAI account. Now, go ahead and generate an API key from the following link: https://platform.openai.com/account/api-keys

Hello, World!

Once you've completed the aforementioned steps, let's write our very first program with OpenAI.NET as follows:

OpenAI.NET Nuget

Find our nuget package.

Program.cs

The following example demonstrate how you can write your first Completions program.

var openAiApiConfigurations = new ApiConfigurations
{
	ApiKey = "YOUR_API_KEY_HERE",
	OrganizationId = "YOUR_OPTIONAL_ORG_ID_HERE"
}

var openAiClient = new OpenAIClient(openAiApiConfigurations);

var inputCompletion = new Completion
{
	Request = new CompletionRequest
	{
		Prompts = new string[] {"Human: Hello!"}
		Model = "text-davinci-003"
	};
}

Completion resultCompletion =
	await this.openAiClient.Completions.PostCompletionAsync(
		inputCompletion);

Array.ForEach(resultCompletion.Response.Prompts, Console.WriteLine);

How to Contribute

If you want to contribute to this project please review the following documents:

If you have a question make sure you either open an issue or join our The Standard Community discord server.

Live-Sessions

Our live-sessions are schedules on The Standard Calendar make sure you adjust the time to your city/timezone to to be able to join us.

We broadcast on multiple platforms:
YouTube
LinkedIn
Twitch
Twitter
Facebook

Past-Sessions

Here's our live sessions to show you how this library was developed from scratch:

OPENAI000: Getting Started

OPENAI001: API Integrations

OPENAI002: API Integrations

OPENAI003: API Integrations

OPENAI004: Completion Service

OPENAI005: Completion Service

OPENAI006: Developing Completion Clients

OPENAI007: Acceptance & Integration Tests

About

Standard-Compliant .NET library for Open AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%