cc-switch DeepSeek usage statistics inaccurate / balance query fails
Quick fix
Upgrade to v3.19.2 and rebuild Codex usage. The balance query needs a correct {{apiKey}}, or a proxy.
Symptom
Section titled “Symptom”使用统计中codex接入deepseek用量不更新In usage statistics, DeepSeek usage through Codex does not update
Three mechanisms sit in this cluster. 1) When a rollout file holds several cumulative counters, the Codex session log importer diffs across counters, inflating usage. A flaw in replay snapshot deduplication then discards genuinely new usage as a duplicate, which shows up as statistics that never update. Fixed in v3.19.2 (PR #5854). 2) The DeepSeek Chat format reports cache hits in prompt_cache_hit_tokens, which the older parsing layer did not read, so cache hits counted as 0 and were billed at the full input rate, disagreeing with the discounted price on the provider site. 3) Leaving {{apiKey}} empty in a usage/balance query script does not fall back to the key in the provider config, and cross-border network timeouts make the query fail. There are also reports of rollout file mtime not updating on Windows, which stalls incremental detection.
Upgrade cc-switch to v3.19.2 or newer.
After upgrading, run 重建 Codex 用量 (rebuild Codex usage) once on the 使用统计 (usage statistics) page. Historically inflated data does not clear itself — a rebuild is required.
When configuring the DeepSeek balance query, make sure the {{apiKey}} field holds a valid API key. Leaving it empty does not fall back to the key in the provider config.
// 供应商设置 → 配置余量查询{request: {url: "{{baseUrl}}/user/balance",method: "GET",headers: {Authorization: "Bearer {{apiKey}}"}}}If the balance query times out without a VPN, note v3.16.3 raised the timeout from 10 to 15 seconds. If it still fails, configure a global proxy in cc-switch.
If Codex usage still does not update after upgrading and rebuilding, check that the matching rollout JSONL file under ~/.codex/sessions/ keeps growing. On Windows the file mtime may not update, stalling incremental detection — try restarting Codex or triggering a rebuild by hand.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 17 real issues
- #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 消耗会异常增加
- #6073使用统计中codex接入deepseek用量不更新
- #6561codex配置deepseek API的是不会统计token用量
- Does historically inflated usage clear itself after upgrading?
- No. You have to run 重建 Codex 用量 (rebuild Codex usage) once on the 使用统计 (usage statistics) page before the numbers return to accurate.
- Does an empty {{apiKey}} fall back to the provider key during a balance query?
- No. This is a known bug (#1658) — you must fill the API key in by hand for the query to work.
- The DeepSeek balance query fails without a VPN. What now?
- v3.16.3 raised the timeout to 15 seconds. If it still fails your network is blocking it, and you need a global proxy configured in cc-switch.
- cc-switch shows my quota draining faster than the provider site. Is something leaking?
- Rule out reporting lag first: both the DeepSeek site and cc-switch usage statistics lag, so wait at least 10 minutes before comparing. If they still disagree, upgrade to v3.19.2 and rebuild usage.
- Token usage is inflated after an OpenCode /fork. What now?
- This is a known bug (#5676): a forked session double-counts the parent session tokens. There is no fix yet — watch that issue.
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.