cc-switch Usage Statistics Differ from DeepSeek Official Site / Stop Updating
Quick fix
Upgrade to v3.19.2 or later, then run “Rebuild Codex Usage” once on the “Usage Statistics” page to correct historical overcounts or missing records.
Symptom
Section titled “Symptom”codex使用deepseek v4 flash,在ccswitch使用统计部分与deepseek官网不一致,使用一段时间后就不在更新When using DeepSeek v4 flash with Codex, the usage statistics in cc-switch differ from the DeepSeek official site and stop updating after some time.
The Codex session log importer has a counter bug: when multiple independent cumulative counters alternate within one rollout file, the old algorithm computes differences across counters, inflating usage by as much as 6 times or more. A deduplication defect when replaying snapshots can also mistake later additional usage for a duplicate and discard it, causing statistics to stop updating. These are the shared root causes of the “does not match the official site” and “stops updating” symptoms. Another independent source of discrepancies is that DeepSeek Chat format uses the provider-specific cache-hit field prompt_cache_hit_tokens (instead of the OpenAI-style prompt_tokens_details.cached_tokens). CC Switch's usage parser and Responses conversion layer previously did not read this field, so all cache hits were recorded as 0 and billed at the full input price, while the DeepSeek official site applies a discounted rate to cache hits, making costs differ. Note that the official direct endpoint currently returns both fields with the same value, so cache hits from the official direct endpoint have always been read correctly. This gap only affects relays or upstreams that pass through the documented field alone.
Upgrade cc-switch to v3.19.2 or later (this version includes the session importer fix in PR #5854).
Run “Rebuild Codex Usage” once on the “Usage Statistics” page (rebuild). This step is required; historical overcounted data will not disappear automatically.
After rebuilding, compare the statistics with the DeepSeek official site. If they still differ or still stop updating, redact the rollout JSONL files for the affected period under ~/.codex/sessions/ and submit them in an issue for further investigation.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 22 real issues
- #590关于本地代理模式的疑问
- #880对于用量统计相关的一些问题
- #1658用量查询Bug:`{{apiKey}}`留空时不会自动使用供应商配置中的key
- #2527hermes用量查询配置显示错误
- #2591DeepSeek的用量监测显示两个套餐
- #2965硅基流动余额查询不准 ,实际1000,显示600多。
- #3003ClaudeCodeDesktop 使用 deepseek 模型选择 1M 上下文会导致代理的供应商和计费显示异常
- #3358Codex本地路由代理Deepseek后,自动查询余量提示查询失败
- #3379CC-SWITCH转换OpenAI格式opencode go 中的 Deepseek至Authropic缓存失效
- #3923【配置用量】Deepseek API用量查询,翻墙状态可以查,不翻墙查不了
- #3985proxy_request_logs 的 app_type 字段无法正确区分 Claude Desktop 和 Claude Code 请求
- #4312[Bug] 操作 cc-switch / 启动时以当前模型批量重发本机历史会话,导致后台静默计费(本地 usage 记 0)
- #4984疑似恶性bug:额度偷跑
- #4990关于deepseek模型接入之后,无法自动压缩,导致上下文超限之后对话彻底死掉
- #5067我该如何配置packy的用量查询?
- #5676在使用 cc-switch 的用量统计功能时,发现通过 OpenCode 的 `/fork` 命令创建新会话后,统计的 Token 消耗会异常增加
- #5989Proposal: upstream CCSwitchMulti Codex MultiRouter as an optional integration
- #6073使用统计中codex接入deepseek用量不更新
- #6561codex配置deepseek API的是不会统计token用量
- #6993feat(usage): support scripted multi-step login for web-auth-only usage query (用户名密码登录态查用量)
- #7160使用统计「模型」列为空:部分网关流式响应回显 model:"",会话导入把空串原样落库
- #7355我接入了OpenCode Go套餐,每天用一会儿就回报错
- Why is historical usage still incorrect after upgrading to v3.19.2?
- The fix ensures only that newly generated data is correct; historical overcounted data will not disappear automatically. You must manually run “Rebuild Codex Usage” once on the “Usage Statistics” page for the statistics to return to accurate values.
- After upgrading and rebuilding, why do Codex requests through DeepSeek still often stop updating usage statistics, requiring another rebuild to refresh them?
- v3.19.2 fixed the replay deduplication defect, but some users still report needing repeated rebuilds to update statistics. Confirm that you have upgraded to v3.20.0 or later. If the issue persists, redact the rollout JSONL files for the affected period under ~/.codex/sessions/ and submit them to issue #6073 for follow-up.
- Why does cc-switch show 0 cache hits when the DeepSeek official site applies a cache discount?
- DeepSeek Chat format reports cache hits using its provider-specific field prompt_cache_hit_tokens. CC Switch did not previously read this field, so all cache hits were recorded as 0 and billed at the full input price. This was fixed in PR #6126; after upgrading, both the parsing and conversion layers will support this field.
- Why do usage statistics differ from the official site when Claude Code connects directly to the official DeepSeek endpoint?
- The official direct endpoint currently returns both the standard cached_tokens field and the documented prompt_cache_hit_tokens field with the same value, so cache hits from the official direct endpoint have always been read correctly. If there is still a discrepancy, check whether you are using a relay gateway or whether other billing conventions differ.
Related problems
Section titled “Related problems”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.