Skip to content

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.

Error output
使用统计中codex接入deepseek用量不更新
English translation

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.

  1. Upgrade cc-switch to v3.19.2 or newer.

  2. After upgrading, run 重建 Codex 用量 (rebuild Codex usage) once on the 使用统计 (usage statistics) page. Historically inflated data does not clear itself — a rebuild is required.

  3. 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}}"
    }
    }
    }
  4. 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.

  5. 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.

ToolCodex
Version3.14.1 - 3.19.1
PlatformsWindowsmacOSLinux
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.

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.