TokenLedger 0.2.0-preview.2
See the version list below for details.
dotnet add package TokenLedger --version 0.2.0-preview.2
NuGet\Install-Package TokenLedger -Version 0.2.0-preview.2
<PackageReference Include="TokenLedger" Version="0.2.0-preview.2" />
<PackageVersion Include="TokenLedger" Version="0.2.0-preview.2" />
<PackageReference Include="TokenLedger" />
paket add TokenLedger --version 0.2.0-preview.2
#r "nuget: TokenLedger, 0.2.0-preview.2"
#:package TokenLedger@0.2.0-preview.2
#addin nuget:?package=TokenLedger&version=0.2.0-preview.2&prerelease
#tool nuget:?package=TokenLedger&version=0.2.0-preview.2&prerelease
TokenLedger
AI cost and behavior snapshots for .NET apps that use IChatClient.
Record the model's responses once and replay them in CI for free; measure calls, tokens and tool calls per test
scenario; compare them with a baseline committed to the repository and fail on regressions or budgets. Prices are
yours to configure. Works with any Microsoft.Extensions.AI provider, streaming included.
// The chat client: TokenLedger last, closest to the provider. Outside a test scenario it does nothing.
services.AddChatClient(inner).UseFunctionInvocation().UseTokenLedger();
// A test, in any framework:
await using var ledger = Ledger.Scenario("support-chat/order-status");
var answer = await chat.GetResponseAsync("Where is my order 42?");
ledger.Budget(maxCalls: 3, maxTokens: 4_000);
// Disposing the scenario compares the calls with tokenledger/baselines/support-chat/order-status.json.
TOKENLEDGER_MODE = auto (default on your machine), replay (default in CI), record or live.
TOKENLEDGER_UPDATE=1 accepts the current measurements.
Documentation: https://github.com/amondejar/Token-Ledger
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.AI (>= 10.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TokenLedger:
| Package | Downloads |
|---|---|
|
TokenLedger.AspNetCore
TokenLedger for ASP.NET Core integration tests: attributes each model call to the HTTP endpoint that made it (POST api/support/chat makes 3 calls), so baselines and pull request reports show the cost per endpoint, and connects the requests of a test to its scenario with WebApplicationFactory, TestServer or a real host. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.0-preview.1 | 72 | 10/26/2026 |
| 0.2.0-preview.2 | 63 | 10/24/2026 |
| 0.2.0-preview.1 | 65 | 10/24/2026 |
| 0.1.0-preview.1 | 68 | 10/24/2026 |