Path: redb-route/redb.Route.Llm/Engine/Governance/ICostCalculator.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm/Engine/Governance/ICostCalculator.cs ---- using redb.Route.Llm.Providers; namespace redb.Route.Llm.Engine.Governance; /// /// Prices one provider response so a cost budget can be enforced. The engine asks this once per /// iteration and once before the first call (to prove the model can be priced at all). /// /// Return null only when this deployment cannot price the call at all — a model whose rates it /// does not know. A calculator that knows the rates returns 0m for zero usage; returning /// null there would make the engine refuse a cost-budgeted run it could actually enforce. /// /// public interface ICostCalculator { /// Estimated cost in USD for one response, or null when the model cannot be priced. /// Token usage reported by the provider for the call. /// The connection factory the call was made through (model id, provider id). decimal? Estimate(LlmUsage usage, LlmConnectionFactory factory); } /// /// Default calculator: prices nothing. Registered by AddRedbRouteLlm() so the engine always has /// a calculator to ask; a run that requests a cost budget while this one is registered fails fast /// instead of silently enforcing a zero ceiling. /// public sealed class NullCostCalculator : ICostCalculator { /// public decimal? Estimate(LlmUsage usage, LlmConnectionFactory factory) => null; }