VOOZH about

URL: https://www.nuget.org/packages/soenneker.semantickernel.pool/

⇱ NuGet Gallery | Soenneker.SemanticKernel.Pool 4.0.330




👁 Image
Soenneker.SemanticKernel.Pool 4.0.330

Prefix Reserved
dotnet add package Soenneker.SemanticKernel.Pool --version 4.0.330
 
 
NuGet\Install-Package Soenneker.SemanticKernel.Pool -Version 4.0.330
 
 
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.330" />
 
 
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.330" />
 
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.330
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.SemanticKernel.Pool, 4.0.330"
 
 
#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.330
 
 
#: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.330
 
Install as a Cake Addin
#tool nuget:?package=Soenneker.SemanticKernel.Pool&version=4.0.330
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 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

👁 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 Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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.Gemini

Provides Gemini-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.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.330 81 6/17/2026
4.0.329 333 6/10/2026
4.0.328 282 6/10/2026
4.0.327 394 6/7/2026
4.0.326 239 6/6/2026
4.0.325 202 6/6/2026
4.0.324 178 6/6/2026
4.0.323 179 6/5/2026
4.0.322 164 6/5/2026
4.0.319 394 5/28/2026
4.0.318 117 5/28/2026
4.0.317 320 5/13/2026
4.0.316 263 5/12/2026
4.0.315 273 5/11/2026
4.0.314 124 5/11/2026
4.0.313 326 5/2/2026
4.0.312 209 5/1/2026
4.0.311 173 4/30/2026
4.0.310 161 4/29/2026
4.0.309 299 4/24/2026
Loading failed

Update dependency Soenneker.SemanticKernel.Cache to 4.0.770 (#727)