Soenneker.SemanticKernel.Pool 3.0.21

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.SemanticKernel.Pool --version 3.0.21
                    
NuGet\Install-Package Soenneker.SemanticKernel.Pool -Version 3.0.21
                    
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.SemanticKernel.Pool" Version="3.0.21" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.SemanticKernel.Pool" Version="3.0.21" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.SemanticKernel.Pool" />
                    
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.SemanticKernel.Pool --version 3.0.21
                    
#r "nuget: Soenneker.SemanticKernel.Pool, 3.0.21"
                    
#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.SemanticKernel.Pool@3.0.21
                    
#: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.SemanticKernel.Pool&version=3.0.21
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Pool&version=3.0.21
                    
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.SemanticKernel.Pool

A high-performance, thread-safe pool implementation for Microsoft Semantic Kernel instances with built-in rate limiting capabilities.

Features

  • Kernel Pooling: Efficiently manages and reuses Semantic Kernel instances
  • Rate Limiting: Built-in support for request rate limiting at multiple time windows:
    • Per-second rate limiting
    • Per-minute rate limiting
    • Per-day rate limiting
    • Token-based rate limiting
  • Thread Safety: Fully thread-safe implementation using concurrent collections
  • Async Support: Modern async/await patterns throughout the codebase
  • Flexible Configuration: Configurable rate limits and pool settings
  • Resource Management: Automatic cleanup of expired rate limit windows

Installation

dotnet add package Soenneker.SemanticKernel.Pool
services.AddSemanticKernelPoolAsSingleton()

Extension Packages

This library has several extension packages for different AI providers:

Usage

Startup Configuration

// In Program.cs or Startup.cs
public class Program
{
    public static async Task Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        
        // Add the kernel pool as a singleton
        builder.Services.AddSemanticKernelPoolAsSingleton();

        var app = builder.Build();

        // Register kernels during startup
        var kernelPool = app.Services.GetRequiredService<ISemanticKernelPool>();
        
        // Manually create options, or use one of the extensions mentioned above
        var options = new SemanticKernelOptions
        {
            ApiKey = "your-api-key",
            Endpoint = "https://api.openai.com/v1",
            Model = "gpt-4",
            KernelFactory = async (opts, _) =>
            {
                return Kernel.CreateBuilder()
                             .AddOpenAIChatCompletion(modelId: opts.ModelId!,
                                 new OpenAIClient(new ApiKeyCredential(opts.ApiKey), new OpenAIClientOptions {Endpoint = new Uri(opts.Endpoint)}));
            }

            // Rate Limiting
            RequestsPerSecond = 10,
            RequestsPerMinute = 100,
            RequestsPerDay = 1000,
            TokensPerDay = 10000
        };

        await kernelPool.Register("my-kernel", options);

        // Add more registrations... order matters!

        await app.RunAsync();
    }
}

Using the Pool

public class MyService
{
    private readonly ISemanticKernelPool _kernelPool;

    public MyService(ISemanticKernelPool kernelPool)
    {
        _kernelPool = kernelPool;
    }

    public async Task ProcessAsync()
    {
        // Get an available kernel that's within its rate limits, preferring the first registered
        var (kernel, entry) = await _kernelPool.GetAvailableKernel();

        // Get the chat completion service
        var chatCompletionService = kernel.GetService<IChatCompletionService>();

        // Create a chat history
        var chatHistory = new ChatHistory();
        chatHistory.AddMessage(AuthorRole.User, "What is the capital of France?");

        // Execute chat completion
        var response = await chatCompletionService.GetChatMessageContentAsync(chatHistory);

        Console.WriteLine($"Response: {response.Content}");

        // Access rate limit information through the entry
        var remainingQuota = await entry.RemainingQuota();
        Console.WriteLine($"Remaining requests - Second: {remainingQuota.Second}, Minute: {remainingQuota.Minute}, Day: {remainingQuota.Day}");
    }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  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 (5)

Showing the top 5 NuGet packages that depend on Soenneker.SemanticKernel.Pool:

Package Downloads
Soenneker.SemanticKernel.Pool.Ollama

Provides Ollama-specific registration extensions for KernelPoolManager, enabling integration with local LLMs via Semantic Kernel.

Soenneker.SemanticKernel.Pool.OpenAi

Provides OpenAI-specific registration extensions for KernelPoolManager, enabling integration with local LLMs via Semantic Kernel.

Soenneker.SemanticKernel.Pool.OpenAi.Azure

Provides Azure OpenAI-specific registration extensions for KernelPoolManager, enabling integration with local LLMs via Semantic Kernel.

Soenneker.SemanticKernel.Pool.Gemini

Provides Gemini-specific registration extensions for KernelPoolManager, enabling integration with local LLMs via Semantic Kernel.

Soenneker.SemanticKernel.Pool.Mistral

Provides Mistral-specific registration extensions for KernelPoolManager, enabling integration via Semantic Kernel.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.187 24 1/3/2026
4.0.186 75 1/3/2026
4.0.185 54 1/3/2026
4.0.184 63 1/3/2026
4.0.183 52 1/3/2026
4.0.182 40 1/2/2026
4.0.181 66 1/2/2026
4.0.180 89 1/2/2026
4.0.179 146 12/31/2025
4.0.178 118 12/31/2025
4.0.177 91 12/31/2025
4.0.176 128 12/31/2025
4.0.175 273 12/22/2025
4.0.174 283 12/21/2025
4.0.173 208 12/21/2025
4.0.172 251 12/20/2025
4.0.171 259 12/20/2025
4.0.170 244 12/19/2025
4.0.169 404 12/17/2025
4.0.168 342 12/16/2025
4.0.167 296 12/15/2025
4.0.166 305 12/15/2025
4.0.165 306 12/15/2025
4.0.164 270 12/15/2025
4.0.163 234 12/13/2025
4.0.162 185 12/13/2025
4.0.161 178 12/12/2025
4.0.160 472 12/10/2025
4.0.159 455 12/10/2025
4.0.158 497 12/10/2025
4.0.157 494 12/10/2025
4.0.156 448 12/10/2025
4.0.155 551 12/9/2025
4.0.154 247 12/3/2025
4.0.153 481 11/21/2025
4.0.152 379 11/21/2025
4.0.151 450 11/21/2025
4.0.150 446 11/21/2025
4.0.149 429 11/20/2025
4.0.148 388 11/20/2025
4.0.147 484 11/12/2025
4.0.146 312 11/11/2025
4.0.145 367 11/11/2025
4.0.144 319 11/11/2025
4.0.143 349 11/11/2025
4.0.142 353 11/10/2025
4.0.141 226 11/7/2025
4.0.140 207 11/7/2025
4.0.139 181 11/7/2025
4.0.138 227 11/7/2025
4.0.137 248 11/7/2025
4.0.136 234 11/6/2025
4.0.135 233 11/6/2025
4.0.134 354 11/4/2025
4.0.133 241 11/4/2025
4.0.132 235 11/4/2025
4.0.131 236 11/4/2025
4.0.130 213 11/4/2025
4.0.129 230 11/3/2025
4.0.128 307 10/30/2025
4.0.127 271 10/30/2025
4.0.126 241 10/30/2025
4.0.125 230 10/30/2025
4.0.124 258 10/30/2025
4.0.123 220 10/29/2025
3.0.122 275 10/29/2025
3.0.121 307 10/24/2025
3.0.120 323 10/16/2025
3.0.119 295 10/16/2025
3.0.118 261 10/15/2025
3.0.117 227 10/15/2025
3.0.116 340 10/9/2025
3.0.115 411 10/8/2025
3.0.114 259 10/8/2025
3.0.113 293 9/30/2025
3.0.112 493 9/16/2025
3.0.111 364 9/16/2025
3.0.110 326 9/11/2025
3.0.109 240 9/10/2025
3.0.108 312 9/9/2025
3.0.107 215 9/9/2025
3.0.106 229 9/9/2025
3.0.105 193 9/9/2025
3.0.104 228 9/9/2025
3.0.103 379 9/5/2025
3.0.102 276 9/4/2025
3.0.101 319 9/4/2025
3.0.100 232 9/3/2025
3.0.99 260 9/3/2025
3.0.98 265 9/3/2025
3.0.97 204 9/3/2025
3.0.96 266 9/3/2025
3.0.95 194 9/3/2025
3.0.94 379 8/28/2025
3.0.93 267 8/27/2025
3.0.92 285 8/20/2025
3.0.91 260 8/17/2025
3.0.90 340 8/15/2025
3.0.89 278 8/14/2025
3.0.88 255 8/13/2025
3.0.87 316 8/12/2025
3.0.86 266 8/12/2025
3.0.85 185 8/12/2025
3.0.84 271 8/11/2025
3.0.83 191 8/11/2025
3.0.82 295 8/11/2025
3.0.81 179 8/11/2025
3.0.80 422 8/11/2025
3.0.79 194 8/11/2025
3.0.78 440 8/6/2025
3.0.77 362 8/5/2025
3.0.76 268 8/5/2025
3.0.75 344 8/5/2025
3.0.74 406 8/5/2025
3.0.73 252 7/30/2025
3.0.72 170 7/30/2025
3.0.71 564 7/25/2025
3.0.70 542 7/24/2025
3.0.69 436 7/9/2025
3.0.68 246 7/9/2025
3.0.67 224 7/9/2025
3.0.66 182 7/9/2025
3.0.65 238 7/9/2025
3.0.64 245 7/8/2025
3.0.63 491 7/4/2025
3.0.62 371 7/2/2025
3.0.61 368 6/28/2025
3.0.60 152 6/28/2025
3.0.59 215 6/28/2025
3.0.58 239 6/28/2025
3.0.57 131 6/27/2025
3.0.56 174 6/27/2025
3.0.55 297 6/26/2025
3.0.54 259 6/25/2025
3.0.53 267 6/25/2025
3.0.52 242 6/25/2025
3.0.51 409 6/17/2025
3.0.50 436 6/11/2025
3.0.49 409 6/11/2025
3.0.48 415 6/11/2025
3.0.47 462 6/11/2025
3.0.46 398 6/11/2025
3.0.45 436 6/10/2025
3.0.44 427 6/3/2025
3.0.43 262 6/3/2025
3.0.42 258 6/3/2025
3.0.41 221 6/3/2025
3.0.40 225 6/3/2025
3.0.39 229 6/3/2025
3.0.38 266 6/3/2025
3.0.37 241 6/2/2025
3.0.36 343 5/28/2025
3.0.35 278 5/28/2025
3.0.34 280 5/28/2025
3.0.33 214 5/28/2025
3.0.32 284 5/27/2025
3.0.31 248 5/27/2025
3.0.30 198 5/27/2025
3.0.29 324 5/27/2025
3.0.28 301 5/26/2025
3.0.27 198 5/25/2025
3.0.26 193 5/25/2025
3.0.25 177 5/23/2025
3.0.24 206 5/23/2025
3.0.23 186 5/23/2025
3.0.22 181 5/23/2025
3.0.21 196 5/23/2025
3.0.20 213 5/23/2025
3.0.19 209 5/22/2025
3.0.18 194 5/22/2025
3.0.17 486 5/22/2025
3.0.16 219 5/21/2025
3.0.15 276 5/20/2025
3.0.14 250 5/19/2025
3.0.13 231 5/19/2025
3.0.12 187 5/19/2025
3.0.11 189 5/19/2025
3.0.10 230 5/19/2025
3.0.9 194 5/19/2025
3.0.8 300 5/19/2025
3.0.7 193 5/18/2025
3.0.6 207 5/18/2025
3.0.5 201 5/18/2025
3.0.4 190 5/18/2025
3.0.3 185 5/18/2025
3.0.2 187 5/18/2025
3.0.1 188 5/18/2025