Skip to content

Qwen Data Source (Experimental)

Qwen support is experimental. Expect breaking changes while both ccusage and Qwen Code continue to evolve.

ccusage can read Qwen Code chat JSONL files as one of its supported local data sources, using the same focused and all-source report views as the rest of ccusage.

Focused Views

bash
bunx ccusage qwen --help
bash
npx ccusage@latest qwen --help
bash
pnpm dlx ccusage qwen --help

Data Source

The CLI reads Qwen chat JSONL files from QWEN_DATA_DIR (defaults to ~/.qwen). QWEN_DATA_DIR can be one directory or a comma-separated list of directories.

bash
QWEN_DATA_DIR="$HOME/.qwen,/backup/qwen" ccusage qwen daily
text
~/.qwen/
└── projects/
    └── {project}/
        └── chats/
            └── *.jsonl

Report Views

Focused viewDescriptionSee also
ccusage qwen dailyAggregate usage by dateDaily Usage
ccusage qwen monthlyAggregate usage by monthMonthly Usage
ccusage qwen sessionGroup usage by Qwen sessionSession Usage

These views support --json for structured output, --compact for narrow terminals, and --offline for cached pricing data.

What Gets Calculated

  • Token usage - Qwen assistant rows provide input and output token counts through usageMetadata.
  • Reasoning tokens - thoughtsTokenCount is included in totalTokens and priced as output tokens when pricing data is available.
  • Cache tokens - cachedContentTokenCount is treated as cache read tokens. Qwen logs do not currently expose cache creation tokens.
  • Pricing - Costs are calculated from LiteLLM pricing data using the raw model name and Qwen provider-prefixed candidates.

Environment Variables

VariableDescription
QWEN_DATA_DIROverride the root directory, or comma-separated root directories, containing Qwen data
LOG_LEVELAdjust verbosity (0 silent ... 5 trace)

Troubleshooting

No Qwen usage data found

Ensure the data directory exists at ~/.qwen/projects/{project}/chats/. Set QWEN_DATA_DIR if your Qwen data lives elsewhere or in multiple archive roots.

Costs showing as $0.00

If a model is not in LiteLLM's database, the cost will be $0.00. Open an issue to request alias support.

Released under the MIT License.