Soenneker.SemanticKernel.Pool 4.0.207

Prefix Reserved
dotnet add package Soenneker.SemanticKernel.Pool --version 4.0.207
                    
NuGet\Install-Package Soenneker.SemanticKernel.Pool -Version 4.0.207
                    
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="4.0.207" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.SemanticKernel.Pool" Version="4.0.207" />
                    
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 4.0.207
                    
#r "nuget: Soenneker.SemanticKernel.Pool, 4.0.207"
                    
#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@4.0.207
                    
#: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=4.0.207
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Pool&version=4.0.207
                    
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 and async locking
  • 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

// 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();

        // Get the pool service
        var kernelPool = app.Services.GetRequiredService<ISemanticKernelPool>();

        // Create SemanticKernelOptions (example uses OpenAI)
        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
        };

        // Register one or more entries under a "sub-pool-1" sub-pool
        // poolId: "sub-pool-1", entryKey: "entry1"
        await kernelPool.Register("sub-pool-1", "entry1", options);

        // You can register additional entries (with different entryKey or options)
        // await kernelPool.Register("sub-pool-1", "entry2", otherOptions);

        await app.RunAsync();
    }
}

Working with Sub-Pools

Each call to Register(...) creates a new “entry” under the specified poolId. Entries are checked out in the order they were added (round-robin), subject to rate limits. You can have multiple sub-pools by choosing different poolId strings:

// Register two separate sub-pools
await kernelPool.Register("reasoning", "o4-mini-high", reasoningOptions);
await kernelPool.Register("high-performance", "4o", highPerformanceOptions);

Retrieving an Available Kernel

public class MyService
{
    private readonly ISemanticKernelPool _kernelPool;

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

    public async Task ProcessAsync()
    {
        // Attempt to get an available kernel from the "my-kernel" sub-pool
        // If no type is provided, defaults to KernelType.Chat
        var (kernel, entry) = await _kernelPool.GetAvailableKernel("my-kernel");

        if (kernel is null || entry is null)
        {
            Console.WriteLine("No available kernel or operation was cancelled.");
            return;
        }

        // Use the kernel as usual
        var chatCompletion = kernel.GetService<IChatCompletionService>();

        var chatHistory = new ChatHistory();
        chatHistory.AddMessage(AuthorRole.User, "What's the capital of France?");

        var response = await chatCompletion.GetChatMessageContentAsync(chatHistory);
        Console.WriteLine($"Response: {response.Content}");

        // Check rate limit usage
        var remaining = await entry.RemainingQuota();
        Console.WriteLine($"Remaining quotas — Second: {remaining.Second}, Minute: {remaining.Minute}, Day: {remaining.Day}");
    }
}

Unregistering and Clearing

  • Remove a single entry from a sub-pool

    bool removed = await kernelPool.Remove("sub-pool-1", "entry1");
    
  • Clear a single sub-pool (removes all entries under that poolId and clears cache for those entries)

    await kernelPool.Clear("sub-pool-1");
    
  • Clear all sub-pools (removes every poolId, all entries, and clears the entire cache)

    await kernelPool.ClearAll();
    
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 (5)

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

Package Downloads
Soenneker.SemanticKernel.Pool.OpenAi

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

Soenneker.SemanticKernel.Pool.Ollama

Provides Ollama-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.207 62 1/9/2026
4.0.206 60 1/9/2026
4.0.205 66 1/9/2026
4.0.204 57 1/9/2026
4.0.203 81 1/9/2026
4.0.202 62 1/8/2026
4.0.201 57 1/8/2026
4.0.200 59 1/8/2026
4.0.199 125 1/8/2026
4.0.198 109 1/8/2026
4.0.197 126 1/7/2026
4.0.196 118 1/7/2026
4.0.195 95 1/7/2026
4.0.194 178 1/7/2026
4.0.193 111 1/7/2026
4.0.192 123 1/6/2026
4.0.191 160 1/6/2026
4.0.190 206 1/5/2026
4.0.189 150 1/5/2026
4.0.188 128 1/5/2026
4.0.187 196 1/3/2026
4.0.186 221 1/3/2026
4.0.185 141 1/3/2026
4.0.184 149 1/3/2026
4.0.183 126 1/3/2026
4.0.182 101 1/2/2026
4.0.181 149 1/2/2026
4.0.180 219 1/2/2026
4.0.179 192 12/31/2025
4.0.178 147 12/31/2025
4.0.177 110 12/31/2025
4.0.176 168 12/31/2025
4.0.175 277 12/22/2025
4.0.174 288 12/21/2025
4.0.173 214 12/21/2025
4.0.172 254 12/20/2025
4.0.171 260 12/20/2025
4.0.170 248 12/19/2025
4.0.169 405 12/17/2025
4.0.168 343 12/16/2025
4.0.167 300 12/15/2025
4.0.166 307 12/15/2025
4.0.165 314 12/15/2025
4.0.164 273 12/15/2025
4.0.163 240 12/13/2025
4.0.162 188 12/13/2025
4.0.161 184 12/12/2025
4.0.160 477 12/10/2025
4.0.159 460 12/10/2025
4.0.158 500 12/10/2025
4.0.157 498 12/10/2025
4.0.156 450 12/10/2025
4.0.155 556 12/9/2025
4.0.154 252 12/3/2025
4.0.153 485 11/21/2025
4.0.152 384 11/21/2025
4.0.151 455 11/21/2025
4.0.150 449 11/21/2025
4.0.149 433 11/20/2025
4.0.148 392 11/20/2025
4.0.147 487 11/12/2025
4.0.146 315 11/11/2025
4.0.145 368 11/11/2025
4.0.144 321 11/11/2025
4.0.143 355 11/11/2025
4.0.142 358 11/10/2025
4.0.141 233 11/7/2025
4.0.140 211 11/7/2025
4.0.139 185 11/7/2025
4.0.138 231 11/7/2025
4.0.137 252 11/7/2025
4.0.136 237 11/6/2025
4.0.135 239 11/6/2025
4.0.134 356 11/4/2025
4.0.133 244 11/4/2025
4.0.132 239 11/4/2025
4.0.131 241 11/4/2025
4.0.130 218 11/4/2025
4.0.129 233 11/3/2025
4.0.128 310 10/30/2025
4.0.127 275 10/30/2025
4.0.126 246 10/30/2025
4.0.125 234 10/30/2025
4.0.124 262 10/30/2025
4.0.123 225 10/29/2025
3.0.122 280 10/29/2025
3.0.121 309 10/24/2025
3.0.120 326 10/16/2025
3.0.119 299 10/16/2025
3.0.118 263 10/15/2025
3.0.117 230 10/15/2025
3.0.116 345 10/9/2025
3.0.115 412 10/8/2025
3.0.114 261 10/8/2025
3.0.113 297 9/30/2025
3.0.112 494 9/16/2025
3.0.111 369 9/16/2025
3.0.110 327 9/11/2025
3.0.109 243 9/10/2025
3.0.108 316 9/9/2025
3.0.107 217 9/9/2025
3.0.106 233 9/9/2025
3.0.105 196 9/9/2025
3.0.104 232 9/9/2025
3.0.103 382 9/5/2025
3.0.102 279 9/4/2025
3.0.101 323 9/4/2025
3.0.100 235 9/3/2025
3.0.99 264 9/3/2025
3.0.98 267 9/3/2025
3.0.97 206 9/3/2025
3.0.96 270 9/3/2025
3.0.95 195 9/3/2025
3.0.94 381 8/28/2025
3.0.93 268 8/27/2025
3.0.92 290 8/20/2025
3.0.91 260 8/17/2025
3.0.90 342 8/15/2025
3.0.89 281 8/14/2025
3.0.88 258 8/13/2025
3.0.87 319 8/12/2025
3.0.86 269 8/12/2025
3.0.85 187 8/12/2025
3.0.84 272 8/11/2025
3.0.83 194 8/11/2025
3.0.82 297 8/11/2025
3.0.81 184 8/11/2025
3.0.80 424 8/11/2025
3.0.79 195 8/11/2025
3.0.78 443 8/6/2025
3.0.77 365 8/5/2025
3.0.76 270 8/5/2025
3.0.75 348 8/5/2025
3.0.74 407 8/5/2025
3.0.73 255 7/30/2025
3.0.72 171 7/30/2025
3.0.71 565 7/25/2025
3.0.70 543 7/24/2025
3.0.69 439 7/9/2025
3.0.68 251 7/9/2025
3.0.67 224 7/9/2025
3.0.66 184 7/9/2025
3.0.65 238 7/9/2025
3.0.64 247 7/8/2025
3.0.63 494 7/4/2025
3.0.62 376 7/2/2025
3.0.61 370 6/28/2025
3.0.60 154 6/28/2025
3.0.59 219 6/28/2025
3.0.58 241 6/28/2025
3.0.57 132 6/27/2025
3.0.56 176 6/27/2025
3.0.55 299 6/26/2025
3.0.54 260 6/25/2025
3.0.53 268 6/25/2025
3.0.52 244 6/25/2025
3.0.51 412 6/17/2025
3.0.50 438 6/11/2025
3.0.49 413 6/11/2025
3.0.48 416 6/11/2025
3.0.47 465 6/11/2025
3.0.46 401 6/11/2025
3.0.45 437 6/10/2025
3.0.44 429 6/3/2025
3.0.43 265 6/3/2025
3.0.42 260 6/3/2025
3.0.41 224 6/3/2025
3.0.40 229 6/3/2025
3.0.39 231 6/3/2025
3.0.38 271 6/3/2025
3.0.37 245 6/2/2025
3.0.36 347 5/28/2025
3.0.35 282 5/28/2025
3.0.34 281 5/28/2025
3.0.33 218 5/28/2025
3.0.32 287 5/27/2025
3.0.31 253 5/27/2025
3.0.30 203 5/27/2025
3.0.29 330 5/27/2025
3.0.28 303 5/26/2025
3.0.27 201 5/25/2025
3.0.26 196 5/25/2025
3.0.25 178 5/23/2025
3.0.24 207 5/23/2025
3.0.23 191 5/23/2025
3.0.22 183 5/23/2025
3.0.21 199 5/23/2025
3.0.20 215 5/23/2025
3.0.19 210 5/22/2025
3.0.18 197 5/22/2025
3.0.17 488 5/22/2025
3.0.16 222 5/21/2025
3.0.15 280 5/20/2025
3.0.14 252 5/19/2025
3.0.13 235 5/19/2025
3.0.12 189 5/19/2025
3.0.11 194 5/19/2025
3.0.10 232 5/19/2025
3.0.9 198 5/19/2025
3.0.8 303 5/19/2025
3.0.7 196 5/18/2025
3.0.6 209 5/18/2025
3.0.5 203 5/18/2025
3.0.4 191 5/18/2025
3.0.3 189 5/18/2025
3.0.2 188 5/18/2025
3.0.1 189 5/18/2025