cc-switch usage query fails / keeps showing failed / undefined / base_url cannot be empty
Quick fix
Upgrade to v3.16.2+. If it still fails, fill in base_url and the access token in NewAPI format, or turn off auto-refresh and the usage query.
Symptom
Section titled “Symptom”配置用量查询失败后,一直显示查询失败After the usage query configuration fails, it keeps showing the query as failed
This cluster covers several kinds of problem. Early versions had a UI crash, the auto-update interval being reset to 0, several providers sharing one usage config so settings bled across, a custom template reverting to the NewAPI template after saving, and a custom script complaining that base_url cannot be empty. v3.16.1 fixed the mismatch between the main screen's refresh-usage path and the credential parsing on the config page. If it still fails after upgrading to v3.16.2, the usual cause is that the upstream endpoint format, access token, or base_url does not meet NewAPI requirements, or upstream does not support usage queries at all. Two problems remain unresolved: the QuickJS extractor is pinned to UTC, and model token statistics do not count cache_read_tokens / cache_creation_tokens.
Upgrade cc-switch to v3.16.2 or newer. A maintainer confirmed the credential parsing problem on the main screen refresh-usage path was fixed in v3.16.1.
If the query still fails, reconfigure it in NewAPI format: fill in base_url and the header / access token rather than putting the URL in the custom script alone.
If you do not need automatic queries for now, turn off the usage query / auto-refresh so the failure notice stops showing.
If your extractor uses Date to show a reset time, note QuickJS currently runs in UTC. Add the offset by hand as a stopgap, for example new Date(timestamp + 8 * 3600 * 1000).
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 18 real issues
- #227请问为何查询额度失败,显示undefined
- #397用量自动更新失效
- #4183.9.0-1 版本 用量查询无法切换到自定义
- #495配置用量查询页面频繁出现这个报错
- #558升级到3.9.0,用例查询有2个问题
- #607本地环境检查,检查WSL有问题,导致用量统计不出来
- #626用量查询配置串了
- #650两个使用过程遇到的问题
- #660配置用量 编辑显示的不对
- #676成本统计及实时刷新问题
- #686官方Codex,使用量查询失败
- #1271配置用量查询失败后,一直显示查询失败
- #1372配置了用量查询无法看到使用情况
- #14423.12.X是否使用量统计功能不work了?
- #1636用量查询bug
- #1716用量统计失效
- #1780用量查询bug
- #1941Bug: QuickJS runtime uses UTC timezone, ignoring system local timezone
- The query still fails after upgrading. What now?
- Reopen the issue with your cc-switch version, how you configured it, and reproduction steps. Also confirm whether upstream supports a NewAPI-format usage query at all.
- Why does my custom template revert to the NewAPI / generic template after saving?
- That is an early-version bug, fixed in later releases. Upgrade and save the config again.
- Why does the usage query fail for official Codex?
- A maintainer replied that this case needs upstream support, which the official endpoint did not offer at the time.
- Why are the model token statistics lower than expected?
- The statistics currently count input_tokens + output_tokens only, excluding cache_read_tokens and cache_creation_tokens. That issue is still open.
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.