Skip to content
Tracon

RunCost

Namespace Tracon · Assembly Tracon.Abstractions.dll

Cost of a run. It is computed and written once when the run ends (a price snapshot) — a later change to the price list does not change past values.

public sealed record RunCost : IEquatable<RunCost>

objectRunCost

IEquatable<RunCost>

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

public RunCost()

Gets the cost of the input tokens that were served from the prompt cache, or null when no cache read was priced.

public decimal? CachedInputCost { get; init; }

decimal?

The cached tokens are subtracted from RunCost.InputCost and charged here instead, so the two fields still add up to the run’s input spend and must not be double counted.

An undefined cache rate does not push the run to PricingSource.Unknown: the cached tokens are then priced at the normal input rate and the total stays exactly what it was before this field existed. PricingSource.Unknown means the MODEL price is missing, which is a different fault.

Gets the cache-read price, per million tokens, that produced CachedInputCost. null when no cache rate was applied — either the cache rate is undefined, or the provider reported no cache read at all.

public decimal? CachedInputPricePerMillionTokens { get; init; }

decimal?

Not a cost addend — see RunCost.InputPricePerMillionTokens.

Gets the currency, taken from Tracon:Pricing:Currency.

public string? Currency { get; init; }

string?

Required whenever RunCost.Source is not PricingSource.Unknown: a known price with no currency label is a resolver defect, not a legitimate state.

Gets the input token cost, or null when the price is unknown.

public decimal? InputCost { get; init; }

decimal?

Gets the input price, per million tokens, that produced InputCost. null when the price is unknown.

public decimal? InputPricePerMillionTokens { get; init; }

decimal?

This is not a fourth addend of RunCost.Total: it is the rate, not an amount. Adding it to the cost total would double-count the same charge on a different scale — RunCost.Total sums only RunCost.InputCost, RunCost.OutputCost and RunCost.CachedInputCost.

Gets the output token cost, or null when the price is unknown.

public decimal? OutputCost { get; init; }

decimal?

Gets the output price, per million tokens, that produced OutputCost. null when the price is unknown.

public decimal? OutputPricePerMillionTokens { get; init; }

decimal?

Not a cost addend — see RunCost.InputPricePerMillionTokens.

Gets where the price came from.

public required PricingSource Source { get; init; }

PricingSource

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(RunCost? other)

other RunCost?

bool

public override int GetHashCode()

int

public override string ToString()

string

Gets the run’s total cost — input, output and cache read together.

public decimal? Total()

decimal?

null when the run was never priced at all. Zero would say “it cost nothing”, which is a different claim.

Every caller that needs “what did this run cost” must use THIS, never InputCost + OutputCost. RunCost.CachedInputCost is a third addend, not a subset of RunCost.InputCost: the resolver subtracts the cached tokens out of the input charge and bills them here. A hand written two-term sum under-reports every run that hit the prompt cache — and a quota ceiling computed that way can be exceeded. RunCost.InputPricePerMillionTokens, RunCost.OutputPricePerMillionTokens and RunCost.CachedInputPricePerMillionTokens are rates, not amounts — they must never be added here.

public static bool operator ==(RunCost? left, RunCost? right)

left RunCost?

right RunCost?

bool

public static bool operator !=(RunCost? left, RunCost? right)

left RunCost?

right RunCost?

bool