XBag.AI.Quota.ClientModel
0.1.0-preview.1
dotnet add package XBag.AI.Quota.ClientModel --version 0.1.0-preview.1
NuGet\Install-Package XBag.AI.Quota.ClientModel -Version 0.1.0-preview.1
<PackageReference Include="XBag.AI.Quota.ClientModel" Version="0.1.0-preview.1" />
<PackageVersion Include="XBag.AI.Quota.ClientModel" Version="0.1.0-preview.1" />
<PackageReference Include="XBag.AI.Quota.ClientModel" />
paket add XBag.AI.Quota.ClientModel --version 0.1.0-preview.1
#r "nuget: XBag.AI.Quota.ClientModel, 0.1.0-preview.1"
#:package XBag.AI.Quota.ClientModel@0.1.0-preview.1
#addin nuget:?package=XBag.AI.Quota.ClientModel&version=0.1.0-preview.1&prerelease
#tool nuget:?package=XBag.AI.Quota.ClientModel&version=0.1.0-preview.1&prerelease
XBag.AI.Quota.ClientModel
Retry-After for XBag.AI.Quota with the OpenAI and Azure OpenAI SDKs. Those SDKs (and every
Microsoft.Extensions.AI adapter on top of them) fail with System.ClientModel's ClientResultException, which carries the HTTP
status and the raw response. The core package is provider-free and does not know that type, so without this classifier a 429
from the OpenAI SDK is not retried at all. ClientModelFailures.Classify reads the status and the provider's wait.
Part of the XBag family of .NET packages by Murat Ay, the author of XBag, a .NET process-orchestration and decisioning platform. Community package, not affiliated with Microsoft or OpenAI.
Pipeline slot: none of its own; it is the ClassifyError of UseQuotaLimiter (BELOW FunctionInvokingChatClient).
Install
It brings XBag.AI.Quota and System.ClientModel 1.15.0:
dotnet add package XBag.AI.Quota.ClientModel --prerelease
Example
From RetryTests.cs, run in CI: the provider answers 429 with Retry-After: 20, the
call is repeated exactly 20 seconds later (fake time), buffered and streaming:
var model = new ScriptedChatClient()
.Fail(Provider.RateLimited(retryAfterSeconds: 20)) // new ClientResultException(message, rawResponse)
.ReplyAt(clock, calledAt, "Kargonuz Ankara aktarma merkezinde.");
IChatClient client = model.AsBuilder()
.UseFunctionInvocation()
.UseQuotaLimiter(o => o.ClassifyError = ClientModelFailures.Classify, new QuotaLedger(clock))
.Build();
Task<string> call = client.AskAsync("TR123 nerede?", Ask, streaming);
await clock.AdvanceWhenWaitingAsync(TimeSpan.FromSeconds(20));
Assert.Equal("Kargonuz Ankara aktarma merkezinde.", await call);
Assert.Equal([TimeSpan.FromSeconds(20)], calledAt);
API
| Member | What it is |
|---|---|
ClientModelFailures.Classify(exception) |
For a ClientResultException: 429 → RateLimited; 408, 500, 502, 503, 504 and status 0 (no response: network) → Transient; any other status → NotRetryable; RetryAfter from retry-after-ms, x-ms-retry-after-ms or Retry-After of the raw response. Any other exception → null (the built-in classifier decides). |
Set the SDK's own retries to zero (new OpenAIClientOptions { RetryPolicy = new ClientRetryPolicy(maxRetries: 0) }),
otherwise the SDK has already waited and retried (honouring Retry-After itself) before this classifier ever sees the 429.
What this is not
- Not Azure.Core. Azure SDKs built on
Azure.Corefail withRequestFailedException; that classifier is on the roadmap. - Not a reader of OpenAI's
x-ratelimit-*headers. Only the wait a 429 / 503 asks for is read.
If Microsoft ships a resilience middleware
See the core package's README. MEAI deliberately does not wrap provider exceptions (dotnet/extensions#6774), so a classifier per SDK error type stays useful even if a first-party retry layer appears.
Versions
Depends on XBag.AI.Quota and System.ClientModel 1.15.0 (the version the OpenAI 2.14.0 SDK depends on). Tested on .NET 8 and
.NET 10. Status: 0.1.0-preview.1, the API may change before 1.0.
License
| Product | Versions 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 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. |
-
net10.0
- System.ClientModel (>= 1.15.0)
- XBag.AI.Quota (>= 0.1.0-preview.1)
-
net8.0
- System.ClientModel (>= 1.15.0)
- XBag.AI.Quota (>= 0.1.0-preview.1)
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.1.0-preview.1 | 98 | 10/11/2026 |