Member Junction
    Preparing search index...

    This class serves as the abstract base class for handling price unit types and is used by different price unit types implementations.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Cache-aware cost calculation: prices the three input buckets (uncached/net-new, cache reads, cache writes) at their own per-unit rates, plus output. Cache reads/writes use CacheReadPricePerUnit / CacheWritePricePerUnit when recorded on the cost row; when those are NULL they fall back to InputPricePerUnit, which makes the result identical to the legacy single-bucket pricing. This is the entry point cost calculators should prefer.

      The default implementation here preserves the legacy behavior (all input at the input rate) so any external BasePriceUnitType subclass that only overrides CalculateNormalizedCost keeps working unchanged. The built-in per-unit types below override it to apply per-bucket rates.

      Parameters

      • activeCost: MJAIModelCostEntity
      • uncachedInputTokens: number
      • cacheReadTokens: number
      • cacheWriteTokens: number
      • outputTokens: number

      Returns number

    • Per-bucket cost math shared by the built-in unit types. Cache rates fall back to the input rate when not populated, so cost is unchanged until a model/vendor records a distinct cache rate. All buckets are normalized by the same divisor (e.g. 1,000,000 for per-1M-tokens).

      Parameters

      • divisor: number
      • activeCost: MJAIModelCostEntity
      • uncachedInputTokens: number
      • cacheReadTokens: number
      • cacheWriteTokens: number
      • outputTokens: number

      Returns number