Skip to content

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.

Error output
配置用量查询失败后,一直显示查询失败
English translation

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.

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

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

  3. If you do not need automatic queries for now, turn off the usage query / auto-refresh so the failure notice stops showing.

  4. 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).

Toolcc-switch
Version3.8.2 起持续报告;v3.16.1 修复主界面刷新的凭证解析,建议升级到 v3.16.2 及以上
PlatformsWindowsLinux
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.

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.