Skip to content
.NET · dependency-free core

Token Economy

2026-09-25: The core Luna and Sol routes now use GPT-6. Read the policy, price deltas, and provisional evidence.

Calculate token costs. Choose a model for the work.

A .NET library for dated model prices, token-cost calculations, and model-routing decisions. Use its C# API in your runner, orchestrator, or application.

Explore the API Install the library $ dotnet add package TokenEconomy

Plain, warm, direct language

Compare dated German and English language evidence, six quality dimensions, and measured sample costs. Public research is separate from local model measurements.

Explore human-friendly language →

Pricing, costs, and model routing

Calculate what a run cost, inspect a model’s fit, and decide whether the next attempt can run. The core APIs run in your process and make no model-provider requests.

01

Pricing catalog with history

Look up the price that applied when a run started. Dated entries keep historical calculations tied to the rate used at the time.

02

Cost API

ComputeCost(model, usage, atUtc) → a deterministic per-component breakdown and total. An unknown or unpriced model returns an explicit unknown — never a silent $0.

03

Model routing

ModelRouter.Route(…) combines task difficulty, policy, and supplied capacity. It returns a selected route, a wait decision, or a request for an operator override.

Install

Dependency-free, targets net10.0, ships XML docs and a symbol package. Apache-2.0.

dotnet add package TokenEconomy

Requires the .NET 10 SDK. Add using TokenEconomy; to your C# file, then use ModelPriceCatalog.Default, ModelEfficiencyMatrix.Default, or ModelRouter.Default.

Start with a complete cost calculation · Package releases · Supply your own catalog

Cost API

Provide a TokenUsage value and a UTC instant to ComputeCost. The result is a CostBreakdown with component costs and a nullable total.

using TokenEconomy;

var atUtc = new DateTime(2026, 9, 12, 0, 0, 0, DateTimeKind.Utc);
CostBreakdown cost = ModelPriceCatalog.Default.ComputeCost(
    KnownModels.ClaudeSonnet5,
    new TokenUsage(Input: 1_000_000, Output: 200_000),
    atUtc);

if (cost.HasPrice)
    Console.WriteLine($"{cost.Total:F2} {cost.Currency}"); // 4.00 USD
else
    Console.WriteLine(cost.Status);
Missing prices are explicit. An unknown id returns PriceStatus.UnknownModel; a known model without a price for the requested date returns PriceStatus.NoPriceForDate. In both cases CostBreakdown.Total is null.

Read the result

  • InputCost, OutputCost, CacheReadCost, and CacheWriteCost contain the component values.
  • Total is the sum, or null when no price applies.
  • HasPrice is true only when a concrete price was used.
  • Unconfirmed identifies a provisional catalog rate.

Token components, cache accounting, return fields, and failure cases →

Prices change. Keep the date.

The catalog records sourced rates for every model it lists. A run uses the price effective at its UTC timestamp. For example, Luna’s input and output rates fell 80% on 30 July 2026.

Luna price dateInput / MTokOutput / MTok1M input + 200K output
2026-07-29$1.00$6.00$2.20
2026-07-30$0.20$1.20$0.44

On a subscription, these are API-equivalent consumption amounts. They help compare workloads; the provider’s usage meter determines remaining allowance.

All model prices, dated histories, sources and subscription comparison →

Use ResolvePrice(model, atUtc) for one rate or PriceDevelopment(model) for its full history. API contract

Compare models and reasoning effort

SuggestModel ranks compatible core models for a task. EvaluateModel describes one model you name. Both return model details and a suggested reasoning level; the routing API makes the attempt-admission decision.

What does EvaluateModel return?

A nullable ModelSuggestion. Read SuggestedEffort for the reasoning level, Score for the compatibility rank, and Rationale for its explanation.

using TokenEconomy;

var atUtc = new DateTime(2026, 9, 12, 0, 0, 0, DateTimeKind.Utc);
ModelSuggestion? sonnet = ModelEfficiencyMatrix.Default.EvaluateModel(
    KnownModels.ClaudeSonnet5,
    TaskClass.Feature,
    BudgetPressure.Tight,
    atUtc);

if (sonnet is null)
{
    Console.WriteLine("No evaluation is available for this model and task.");
    return;
}

Console.WriteLine($"Model: {sonnet.ModelId}");
Console.WriteLine($"Reasoning: {sonnet.SuggestedEffort}");
Console.WriteLine($"Fit: {sonnet.Suitability}");
Console.WriteLine($"Cost class: {sonnet.CostClass}");
Output with the current catalog
Model: claude-sonnet-5
Reasoning: Medium
Fit: Capable
Cost class: Standard

Tight changes cost weighting, while this feature task retains Medium reasoning. Sonnet 5 is a fallback-only model in the current policy: evaluating it does not authorize a fallback or launch a run.

All return fields, null cases, and explicit effort →

Ask for a ranked list

using TokenEconomy;

IReadOnlyList<ModelSuggestion> ranked = ModelEfficiencyMatrix.Default.SuggestModel(
    TaskClass.Feature,
    BudgetPressure.Tight,
    availableClis: [Cli.Codex],
    atUtc: new DateTime(2026, 9, 12, 0, 0, 0, DateTimeKind.Utc));

if (ranked.Count == 0)
{
    Console.WriteLine("Wait: no eligible model is available.");
    return;
}

var best = ranked[0];
Console.WriteLine($"{best.ModelId} / {best.SuggestedEffort}");
Console.WriteLine(best.Rationale);

The result is ordered best first. You supply the available CLIs; the method does not check their quota. Fallback-only models are excluded from this list. Read the selection and empty-result contract.

Token-efficiency matrix

ModelEfficiencyMatrix.Default.Describe(asOfUtc) returns model tiers, dated cost classes, supported effort levels, and task suitability. This table adds list prices from ResolvePrice. See how to read both APIs.

✓ selectable↪ fallback only⊘ unsupported△ evidence provisional

Status is permission; provisional means its evidence still needs validation. Open a symbol or a score for the reason, source, and remaining gaps. Status guide

Loading the token-efficiency matrix…

Download the dated matrix snapshot (JSON).

Estimate the work before routing it

Build a 100-point worksheet from the AGT task’s intake: correctness risk, expected scope, required context and uncertainty. Completed comparable runs calibrate token forecasts; hard floors preserve the required level of care.

var card = new ComplexityCard
{
    TaskKey = "DEMO-42", Prompt = "Add a saved provider filter.",
    Project = "Agent Studio", Area = "task-list", TaskType = "feature",
    ReferencedSubsystems = ["task-list", "filter-state"],
    ExpectedChangedLines = 120
};
var estimate = new TaskComplexityEstimator().Estimate(card);
Console.WriteLine($"{estimate.Score}/100 → {estimate.Level}"); // 49/100 → Standard
Console.WriteLine(estimate.ScoreEvidence);

Capture these fields before launch. Expected scope comes from the request and a short repository inspection; later diffs, retries and review results belong to the outcome record. The API returns each criterion’s reason, confidence, forecast ranges and neighbour keys.

Complete code, AGT field mapping, scoring anchors and historical backtesting →

The new audit covers 174 archived AGT cards. Its three authenticated prompt replays show that the default token forecasts need calibration. Read the measured results and limits.

Code review is a capability of its own

Compare which defects a model finds and how many of its findings hold up. Direct review studies expose precision, known-issue coverage and the cost of checking results.

Review findings, published studies and Quality Studio APIs →

One real run, costed by the library

A worked example from checked-in usage evidence: the run reports tokens, and ComputeCost applies the catalog price valid at the run's UTC timestamp.

Loading the run’s token counts and cost breakdown…

About this run.

Download the token counts and calculation (JSON).

Benchmarks

Controlled studies compare coding-agent runs on the same tasks. Read what was measured and where the results apply. Read the methods, limits, results, and provenance →