Skip to content

total_cost_usd not recalculated by cc-switch

Quick fix

Upgrade cc-switch to v3.15.0+ to automatically recalculate historical costs after modifying model pricing.

Error output
模型价格新增/修改后,历史 Codex Session 记录的 total_cost_usd 没有重新计算。
English translation

After adding or modifying model prices, the total_cost_usd in historical Codex Session records is not recalculated.

In older versions, Codex Session usage records calculated and wrote fields such as input_cost_usd, output_cost_usd, and total_cost_usd directly into the proxy_request_logs table upon import. If model prices were not configured at the time of import, costs were fixed at 0; subsequent additions of model prices in the UI did not trigger automatic recalculation of historical data, resulting in correct Token statistics but severely underestimated total costs.

Additionally, other issues in the cluster indicate anomalies in the cc-switch statistics module: for example, Codex Desktop fork records being double-counted (issue #5433) in v3.17.0, and token_count events causing log bloat by 33x due to row-by-row insertion (issue #3190). These problems stem from design flaws in JSONL log parsing and cost calculation logic in early versions.

  1. Upgrade cc-switch to v3.15.0 or later.

  2. Navigate to Settings → Usage Statistics → Cost Pricing, check, and complete missing model (e.g., gpt-5.5) input, output, and cache cost pricing.

  3. Return to the Model Statistics page to refresh data; the new version will automatically recalculate historical costs.

Toolcc-switch
Version3.14.1 及更早版本 (affected range)
PlatformsmacOSWindows
Why are my cache Token prices not calculated correctly?
Early versions recorded cache prices as 0 if not configured during import. Upgrade to v3.15.0+, complete cache read/write costs in Cost Pricing, and resync to fix.
What if historical costs do not change after upgrading?
Ensure you have correctly added the latest price configuration for the corresponding model (e.g., gpt-5.5) in Cost Pricing and manually refreshed the Usage Statistics page. If there is still no change, verify that cc-switch has indeed been updated to v3.15.0 or above.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.