Stef.Microsoft.SemanticKernel.WithRetry 0.0.1-preview-01

Prefix Reserved
This is a prerelease version of Stef.Microsoft.SemanticKernel.WithRetry.
dotnet add package Stef.Microsoft.SemanticKernel.WithRetry --version 0.0.1-preview-01
                    
NuGet\Install-Package Stef.Microsoft.SemanticKernel.WithRetry -Version 0.0.1-preview-01
                    
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="Stef.Microsoft.SemanticKernel.WithRetry" Version="0.0.1-preview-01" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Stef.Microsoft.SemanticKernel.WithRetry" Version="0.0.1-preview-01" />
                    
Directory.Packages.props
<PackageReference Include="Stef.Microsoft.SemanticKernel.WithRetry" />
                    
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 Stef.Microsoft.SemanticKernel.WithRetry --version 0.0.1-preview-01
                    
#r "nuget: Stef.Microsoft.SemanticKernel.WithRetry, 0.0.1-preview-01"
                    
#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 Stef.Microsoft.SemanticKernel.WithRetry@0.0.1-preview-01
                    
#: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=Stef.Microsoft.SemanticKernel.WithRetry&version=0.0.1-preview-01&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Stef.Microsoft.SemanticKernel.WithRetry&version=0.0.1-preview-01&prerelease
                    
Install as a Cake Tool

Microsoft.SemanticKernel.WithRetry

This is an extension for the Microsoft.SemanticKernel to handle 'Rate limit reached' exceptions using retries.

Info

Semantic Kernel is a model-agnostic SDK that empowers developers to build, orchestrate, and deploy AI agents and multi-agent systems. Whether you're building a simple chatbot or a complex multi-agent workflow, Semantic Kernel provides the tools you need with enterprise-grade reliability and flexibility.

This project can be used to handle exceptions like:

HTTP 429 (tokens: rate_limit_exceeded)

Rate limit reached for gpt-4o in organization org-xxxxxxxxxxxxxxxxxxxxxxxx on tokens per min (TPM): Limit 30000, Used 27855, Requested 5405. Please try again in 6.52s. Visit https://platform.openai.com/account/rate-limits to learn more.

Usage for OpenAI

Before

var builder = Kernel.CreateBuilder();

builder.Services.AddOpenAIChatCompletion(
    serviceId: "openai",
    modelId: "gpt-4o",
    apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")!
);

After

var builder = Kernel.CreateBuilder();

builder.Services.AddOpenAIChatCompletionWithRetry(
    modelId: "gpt-4o",
    apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")!
);

Usage for Azure OpenAI

Before

var builder = Kernel.CreateBuilder();

builder.Services.AddAzureOpenAIChatCompletion(
    deploymentName: "gpt-4o",
    apiKey: Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY")!,
    endpoint: Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!
);

After

var builder = Kernel.CreateBuilder();

builder.Services.AddAzureOpenAIChatCompletionWithRetry(
    deploymentName: "gpt-4o",
    apiKey: Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY")!,
    endpoint: Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!
);

Sponsors

Entity Framework Extensions and Dapper Plus are major sponsors and proud to contribute to the development of JsonConverter.

Entity Framework Extensions

Dapper Plus

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1-preview-01 104 2/8/2026

.