EchoCoders.AIServiceWrapper.DependencyInjection 1.0.0

dotnet add package EchoCoders.AIServiceWrapper.DependencyInjection --version 1.0.0                
NuGet\Install-Package EchoCoders.AIServiceWrapper.DependencyInjection -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EchoCoders.AIServiceWrapper.DependencyInjection" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EchoCoders.AIServiceWrapper.DependencyInjection --version 1.0.0                
#r "nuget: EchoCoders.AIServiceWrapper.DependencyInjection, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EchoCoders.AIServiceWrapper.DependencyInjection as a Cake Addin
#addin nuget:?package=EchoCoders.AIServiceWrapper.DependencyInjection&version=1.0.0

// Install EchoCoders.AIServiceWrapper.DependencyInjection as a Cake Tool
#tool nuget:?package=EchoCoders.AIServiceWrapper.DependencyInjection&version=1.0.0                

EchoCoders.AIServiceWrapper.DependencyInjection

This package provides a simple way to integrate OpenAI services into your .NET applications using dependency injection.

Installation

You can install the package via NuGet Package Manager:

Usage

Follow these steps to configure and use the OpenAI service in your application:

  1. Add the OpenAI service to the IServiceCollection:

    In your Startup.cs or Program.cs or wherever you configure your services, use the AddOpenAIService extension method to add the OpenAI service to the IServiceCollection.

  2. Inject and use the IAIService in your application:

    Once the service is registered, you can inject IAIService into your classes and use it.

Configuration

The AddOpenAIService method allows you to configure the OpenAIOptions using a configuration action. Here are some of the properties you can configure:

  • ApiKey: The API key for accessing OpenAI services.
  • URL: The base URL for the OpenAI API (optional, defaults to the official OpenAI API URL).
  • Model: The model name to use for the OpenAI service (optional, defaults to the default model).`

Register OpenAI service

services.AddOpenAIService(options =>
{
    options.APIKey = "your-api-key";
    options.URL = "api-url";//optional
    options.Model= "your-model-name";//optional
});

Example:

HttpClient Configuration

The AddOpenAIService method also adds an HttpClient to the service collection. You can configure this HttpClient as needed.

Example:

License

This project is licensed under the MIT License.

Supported .NET versions

.NET 8 and upper

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 75 3/14/2025