Soenneker.SemanticKernel.Pool
3.0.115
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.SemanticKernel.Pool --version 3.0.115
NuGet\Install-Package Soenneker.SemanticKernel.Pool -Version 3.0.115
<PackageReference Include="Soenneker.SemanticKernel.Pool" Version="3.0.115" />
<PackageVersion Include="Soenneker.SemanticKernel.Pool" Version="3.0.115" />
<PackageReference Include="Soenneker.SemanticKernel.Pool" />
paket add Soenneker.SemanticKernel.Pool --version 3.0.115
#r "nuget: Soenneker.SemanticKernel.Pool, 3.0.115"
#:package Soenneker.SemanticKernel.Pool@3.0.115
#addin nuget:?package=Soenneker.SemanticKernel.Pool&version=3.0.115
#tool nuget:?package=Soenneker.SemanticKernel.Pool&version=3.0.115
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:
- Soenneker.SemanticKernel.Pool.Gemini – Google Gemini integration
- Soenneker.SemanticKernel.Pool.OpenAi – OpenAI/OpenRouter.ai/etc. integration
- Soenneker.SemanticKernel.Pool.Ollama – Ollama integration
- Soenneker.SemanticKernel.Pool.OpenAi.Azure – Azure OpenAI integration
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 | 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. |
-
net9.0
- Soenneker.SemanticKernel.Cache (>= 3.0.541)
- Soenneker.Utils.Delay (>= 3.0.30)
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 |
---|---|---|
3.0.116 | 47 | 10/9/2025 |
3.0.115 | 111 | 10/8/2025 |
3.0.114 | 107 | 10/8/2025 |
3.0.113 | 264 | 9/30/2025 |
3.0.112 | 466 | 9/16/2025 |
3.0.111 | 338 | 9/16/2025 |
3.0.110 | 287 | 9/11/2025 |
3.0.109 | 212 | 9/10/2025 |
3.0.108 | 266 | 9/9/2025 |
3.0.107 | 186 | 9/9/2025 |
3.0.106 | 196 | 9/9/2025 |
3.0.105 | 170 | 9/9/2025 |
3.0.104 | 195 | 9/9/2025 |
3.0.103 | 333 | 9/5/2025 |
3.0.102 | 243 | 9/4/2025 |
3.0.101 | 286 | 9/4/2025 |
3.0.100 | 198 | 9/3/2025 |
3.0.99 | 222 | 9/3/2025 |
3.0.98 | 230 | 9/3/2025 |
3.0.97 | 175 | 9/3/2025 |
3.0.96 | 229 | 9/3/2025 |
3.0.95 | 170 | 9/3/2025 |
3.0.94 | 339 | 8/28/2025 |
3.0.93 | 235 | 8/27/2025 |
3.0.92 | 254 | 8/20/2025 |
3.0.91 | 220 | 8/17/2025 |
3.0.90 | 297 | 8/15/2025 |
3.0.89 | 245 | 8/14/2025 |
3.0.88 | 226 | 8/13/2025 |
3.0.87 | 279 | 8/12/2025 |
3.0.86 | 227 | 8/12/2025 |
3.0.85 | 160 | 8/12/2025 |
3.0.84 | 234 | 8/11/2025 |
3.0.83 | 164 | 8/11/2025 |
3.0.82 | 256 | 8/11/2025 |
3.0.81 | 156 | 8/11/2025 |
3.0.80 | 369 | 8/11/2025 |
3.0.79 | 168 | 8/11/2025 |
3.0.78 | 391 | 8/6/2025 |
3.0.77 | 329 | 8/5/2025 |
3.0.76 | 243 | 8/5/2025 |
3.0.75 | 322 | 8/5/2025 |
3.0.74 | 372 | 8/5/2025 |
3.0.73 | 225 | 7/30/2025 |
3.0.72 | 144 | 7/30/2025 |
3.0.71 | 540 | 7/25/2025 |
3.0.70 | 519 | 7/24/2025 |
3.0.69 | 410 | 7/9/2025 |
3.0.68 | 228 | 7/9/2025 |
3.0.67 | 202 | 7/9/2025 |
3.0.66 | 161 | 7/9/2025 |
3.0.65 | 215 | 7/9/2025 |
3.0.64 | 218 | 7/8/2025 |
3.0.63 | 466 | 7/4/2025 |
3.0.62 | 343 | 7/2/2025 |
3.0.61 | 341 | 6/28/2025 |
3.0.60 | 129 | 6/28/2025 |
3.0.59 | 196 | 6/28/2025 |
3.0.58 | 211 | 6/28/2025 |
3.0.57 | 105 | 6/27/2025 |
3.0.56 | 156 | 6/27/2025 |
3.0.55 | 271 | 6/26/2025 |
3.0.54 | 229 | 6/25/2025 |
3.0.53 | 244 | 6/25/2025 |
3.0.52 | 225 | 6/25/2025 |
3.0.51 | 387 | 6/17/2025 |
3.0.50 | 419 | 6/11/2025 |
3.0.49 | 377 | 6/11/2025 |
3.0.48 | 391 | 6/11/2025 |
3.0.47 | 432 | 6/11/2025 |
3.0.46 | 363 | 6/11/2025 |
3.0.45 | 407 | 6/10/2025 |
3.0.44 | 404 | 6/3/2025 |
3.0.43 | 240 | 6/3/2025 |
3.0.42 | 237 | 6/3/2025 |
3.0.41 | 204 | 6/3/2025 |
3.0.40 | 209 | 6/3/2025 |
3.0.39 | 214 | 6/3/2025 |
3.0.38 | 237 | 6/3/2025 |
3.0.37 | 224 | 6/2/2025 |
3.0.36 | 312 | 5/28/2025 |
3.0.35 | 244 | 5/28/2025 |
3.0.34 | 248 | 5/28/2025 |
3.0.33 | 189 | 5/28/2025 |
3.0.32 | 253 | 5/27/2025 |
3.0.31 | 228 | 5/27/2025 |
3.0.30 | 169 | 5/27/2025 |
3.0.29 | 296 | 5/27/2025 |
3.0.28 | 279 | 5/26/2025 |
3.0.27 | 176 | 5/25/2025 |
3.0.26 | 169 | 5/25/2025 |
3.0.25 | 150 | 5/23/2025 |
3.0.24 | 181 | 5/23/2025 |
3.0.23 | 166 | 5/23/2025 |
3.0.22 | 158 | 5/23/2025 |
3.0.21 | 169 | 5/23/2025 |
3.0.20 | 195 | 5/23/2025 |
3.0.19 | 186 | 5/22/2025 |
3.0.18 | 173 | 5/22/2025 |
3.0.17 | 460 | 5/22/2025 |
3.0.16 | 196 | 5/21/2025 |
3.0.15 | 258 | 5/20/2025 |
3.0.14 | 231 | 5/19/2025 |
3.0.13 | 213 | 5/19/2025 |
3.0.12 | 169 | 5/19/2025 |
3.0.11 | 170 | 5/19/2025 |
3.0.10 | 209 | 5/19/2025 |
3.0.9 | 177 | 5/19/2025 |
3.0.8 | 274 | 5/19/2025 |
3.0.7 | 169 | 5/18/2025 |
3.0.6 | 187 | 5/18/2025 |
3.0.5 | 179 | 5/18/2025 |
3.0.4 | 167 | 5/18/2025 |
3.0.3 | 161 | 5/18/2025 |
3.0.2 | 159 | 5/18/2025 |
3.0.1 | 169 | 5/18/2025 |