usage null - Claude Code Qwen DashScope
Quick fix
Upgrade to cc-switch v3.16.3+, which fixes null streaming usage on the OpenAI-compatible interface automatically.
Symptom
Section titled “Symptom”Cannot read properties of null (reading 'output_tokens')With cc-switch as the local proxy and an upstream provider on the OpenAI-compatible protocol (DashScope/Qwen, OpenRouter, and so on), cc-switch does not inject `stream_options: { include_usage: true }` when converting the Claude Code streaming request into OpenAI format. The upstream then returns no token usage data in the SSE chunks, and the Anthropic `message_delta.usage` field the proxy produces ends up null. The Claude Code client throws when it tries to read the `output_tokens` property of that null.
Issue #3752 also concerns usage, but it describes "usage query broken / display expired", usually the balance detection feature rather than token statistics during inference, and the user reported it recovering by itself — apparently a transient upstream service fluctuation or API change. The usage null in Issue #1957 is missing code logic, resolved by upgrading. Both relate to "usage", but the cause and the fix differ.
Uninstall your current older version of cc-switch
Install cc-switch v3.16.3 or newer
Restart Claude Code or Codex and verify the end of the streaming output carries correct usage data
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- Why are all my token usage figures zero?
- Because an upstream OpenAI-compatible interface (Qwen/DashScope, for instance) does not return usage data in a streaming response by default. On cc-switch v3.16.3+, the tool injects the necessary parameter automatically and fixes this.
- How do I resolve the usage query failure mentioned in Issue #3752?
- If you mean 'balance expired' or 'query failed' shown in the Claude Code interface, that is usually a transient fault or API change at the upstream provider (Volcengine Ark, Bailian), unrelated to the cc-switch code. Wait for the provider to recover, or check your account subscription status. If the error occurs during inference, follow the usage null fix on this page.
- Does Codex hit this problem too?
- Yes. The fix in Issue #1957 covers both the Claude Code and the Codex Chat path, keeping the behaviour consistent in both directions.
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.