Soenneker.Azure.OpenAI.Client 4.0.1030

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Azure.OpenAI.Client --version 4.0.1030
                    
NuGet\Install-Package Soenneker.Azure.OpenAI.Client -Version 4.0.1030
                    
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="Soenneker.Azure.OpenAI.Client" Version="4.0.1030" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Azure.OpenAI.Client" Version="4.0.1030" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Azure.OpenAI.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Azure.OpenAI.Client --version 4.0.1030
                    
#r "nuget: Soenneker.Azure.OpenAI.Client, 4.0.1030"
                    
#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.
#:package Soenneker.Azure.OpenAI.Client@4.0.1030
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Azure.OpenAI.Client&version=4.0.1030
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Azure.OpenAI.Client&version=4.0.1030
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Azure.OpenAI.Client

Creates and caches an API-key-authenticated AzureOpenAIClient for dependency-injected applications.

Installation

dotnet add package Soenneker.Azure.OpenAI.Client

Configuration

{
  "Azure": {
    "OpenAI": {
      "Uri": "https://your-resource.openai.azure.com",
      "ApiKey": "your-api-key"
    }
  }
}

The endpoint must be an absolute HTTPS URI. Store the API key in a secret provider or environment variable, not source-controlled configuration.

Registration and use

using Azure.AI.OpenAI;
using Soenneker.Azure.OpenAI.Client.Abstract;
using Soenneker.Azure.OpenAI.Client.Registrars;

builder.Services.AddAzureOpenAIClientUtilAsSingleton();

public sealed class AzureOpenAIService(IAzureOpenAIClientUtil clientUtil)
{
    public ValueTask<AzureOpenAIClient> GetClient(
        CancellationToken cancellationToken) =>
        clientUtil.Get(cancellationToken);
}

Use the returned Azure client to obtain deployment-specific chat, audio, embedding, or other clients supported by the Azure/OpenAI SDK.

Client options and lifecycle

Call SetOptions() before the first Get() when custom AzureOpenAIClientOptions are required:

clientUtil.SetOptions(new AzureOpenAIClientOptions());
AzureOpenAIClient client = await clientUtil.Get(cancellationToken);
  • The first successful Get() creates the client; later calls return the same instance.
  • SetOptions() after creation throws because a cached client cannot be reconfigured.
  • Endpoint, API key, and options changes require replacing the utility instance.
  • Missing configuration or a non-HTTPS endpoint fails initialization.
  • Let the DI container dispose registered instances.

For deployment-specific wrappers, see Soenneker.Azure.OpenAI.Client.Chat and Soenneker.Azure.OpenAI.Client.Audio.

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

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Soenneker.Azure.OpenAI.Client:

Package Downloads
Soenneker.Azure.OpenAI.Client.Chat

An async thread-safe singleton for the Azure OpenAI Chat (completions) client

Soenneker.Azure.OpenAI.Client.Audio

An async thread-safe singleton for the Azure OpenAI audio client

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1049 110,161 10/1/2026
4.0.1048 30,200 9/29/2026
4.0.1047 8,857 9/29/2026
4.0.1046 17,323 9/25/2026
4.0.1045 122 9/25/2026
4.0.1044 117 9/25/2026
4.0.1043 104 9/25/2026
4.0.1042 94 9/24/2026
4.0.1041 115 9/24/2026
4.0.1040 211 9/16/2026
4.0.1039 154 9/16/2026
4.0.1038 110 9/16/2026
4.0.1037 117 9/15/2026
4.0.1036 129 9/15/2026
4.0.1035 150 9/13/2026
4.0.1034 127 9/13/2026
4.0.1033 118 9/13/2026
4.0.1032 120 9/13/2026
4.0.1031 123 9/12/2026
4.0.1030 93 9/12/2026
Loading failed

Update dependency Soenneker.Extensions.Configuration to 4.0.887 (#1582)