File tree Expand file tree Collapse file tree
DevProxy.Abstractions/LanguageModel Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,15 +54,13 @@ public bool TryGetModelPrices(string modelName, out ModelPrices? prices)
5454
5555 Debug . Assert ( prices != null , "Prices data should not be null here." ) ;
5656
57- // Prices in the data are per 1M tokens
58- // When cached input pricing is available, separate cached tokens
59- // from regular input tokens for accurate cost calculation
57+ // Prices in the data are per 1M tokens.
58+ // When no cached input price is configured, fall back to the
59+ // regular input price so all tokens are billed correctly.
60+ var effectiveCachedPrice = prices . CachedInput > 0 ? prices . CachedInput : prices . Input ;
6061 var regularInputTokens = inputTokens - cachedInputTokens ;
61- var inputCost = prices . Input * ( regularInputTokens / 1_000_000.0 ) ;
62- if ( cachedInputTokens > 0 && prices . CachedInput > 0 )
63- {
64- inputCost += prices . CachedInput * ( cachedInputTokens / 1_000_000.0 ) ;
65- }
62+ var inputCost = ( prices . Input * ( regularInputTokens / 1_000_000.0 ) )
63+ + ( effectiveCachedPrice * ( cachedInputTokens / 1_000_000.0 ) ) ;
6664 var outputCost = prices . Output * ( outputTokens / 1_000_000.0 ) ;
6765
6866 return ( inputCost , outputCost ) ;
You can’t perform that action at this time.
0 commit comments