Skip to content

Usage statistics missing or the query fails - cc-switch

Quick fix

Turn the usage statistics toggle on and check the provider script and protocol limits. Official statistics need Tool Search enabled.

Error output
测试失败: base_url 必须使用 HTTPS 协议(localhost 除外)
English translation

Test failed: base_url must use the HTTPS protocol (except for localhost)

Reports in this cluster centre on cc-switch's usage query / usage statistics feature: statistics missing after an upgrade, a failing test script, odd quota fields, or empty statistics. The reasons differ. In some versions official usage statistics became opt-in, or need Tool Search enabled before anything shows. A custom provider's usage query depends on the request URL you configured, the fields the extractor returns, HTTPS and private-IP restrictions, and whether the provider endpoint works at all. There are also problems with the statistics range, model mapping, and session directory detection. A maintainer noted cc-switch usage statistics still carry a fair number of bugs and that the provider's own data should be treated as authoritative.

  1. If usage statistics are missing from the navigation menu after an upgrade, open the toggle inside the 用量查询 (usage query) button first and confirm official usage statistics are switched on manually.

  2. If 设置 - 关于 - 用量信息 (Settings > About > Usage info) shows 0, tick the Tool Search option and check usage info again.

  3. If the 测试 (test) and 配置用量查询 (configure usage query) buttons are greyed out, delete the provider and add it again so it is not misdetected as an official provider.

  4. If the test script says base_url must use HTTPS, change base_url to HTTPS. localhost is exempt; non-localhost HTTP addresses are blocked.

  5. For a failing Novita AI usage query, do not use the default https://api.novita.ai/v3/user/balance — switch to the working balance detail endpoint.

    cc-switch 供应商用量查询脚本(Novita AI)
    ({
    request: {
    url: "https://api.novita.ai/openapi/v1/billing/balance/detail",
    method: "GET",
    headers: {
    Authorization: "Bearer {{apiKey}}",
    "Content-Type": "application/json",
    Accept: "application/json",
    "User-Agent": "cc-switch/1.0"
    }
    },
    extractor: function (response) {
    var raw = response.availableBalance;
    var units = Number(raw);
    if (raw === undefined || raw === null || !isFinite(units)) {
    return {
    isValid: false,
    invalidMessage: response.message || "Novita 返回缺少 availableBalance"
    };
    }
    return {
    isValid: true,
    planName: "Novita AI",
    remaining: units / 10000,
    unit: "USD"
    };
    }
    })
  6. If usage statistics still look wrong, switch the range to 7d or 30d, and treat the provider dashboard billing data as authoritative.

ToolClaude Code
Version3.14.1 - 3.19.1
PlatformsWindowsmacOS
Why did usage statistics disappear after updating?
In some versions official usage statistics became opt-in — enable it inside the 用量查询 (usage query) button. If usage info reads 0, try ticking the Tool Search option.
Why are the test and configure-usage-query buttons disabled and greyed out?
The provider may have been misdetected as an official provider. Adding it again usually restores them.
Why can an HTTP base_url not do usage statistics?
The usage query used to restrict private IPs and require HTTPS; a non-localhost base_url has to use HTTPS. A maintainer said the over-strict guard will be removed in a later version.
The model statistics in cc-switch do not match provider billing. What now?
A maintainer explained cc-switch usage statistics currently carry a number of bugs — go by the provider's own data.
Are Claude desktop Cowork sessions counted?
An issue points out the statistics mainly scan ~/.claude/projects/, and Cowork sessions do not live there, so they probably are not counted. This is a gap awaiting support rather than a bug.

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.