Qwen Code cost tracking: /stats, token counts, status line
Qwen Code shows usage in /stats: tokens for the session, by day and by month, with an estimated cost per model, and it can export to CSV or JSON. A custom status line gets token counts for the live session but no dollar field.
Everything here comes from the Qwen Code docs, read on 2026-11-25. The commands page was last updated by the maintainers on 2026-11-15. We did not run a Qwen Code build for this page, so if a command is missing in your version, compare it against the docs.
How Qwen Code is paid for
Qwen Code is a CLI, and what you pay depends on what sits behind it. The README says that in a session you run /auth and either sign in with a Qwen account with a Plus or Pro subscription, or configure a provider with an API key. It says the API key route supports OpenAI, Anthropic, Gemini and Qwen APIs and any third-party provider or local model, and that you can switch at runtime.
So there is no single price. On an API key you pay whatever that provider charges per token, and the docs for Qwen Code do not list those rates. On a subscription you pay the plan.
One cost lever is documented. The token caching page says Qwen Code optimizes API costs through token caching when you use API key authentication, and that it “occurs with API key authentication but not with OAuth authentication.”
What Qwen Code shows
From the commands reference:
/stats (or /usage) Open the interactive usage statistics dashboard (Session, Activity, and Efficiency tabs)
/stats model Show per-model token breakdown and estimated cost
/stats tools Show per-tool call counts
/stats skills Show per-skill call counts for the current live session
/stats daily [YYYY-MM-DD] Show daily token usage statistics
/stats monthly [YYYY-MM] Show monthly token usage statistics
/stats export <daily|monthly> [date|month] [--format csv|json] [--output path]
/context Show context window usage breakdown
/context detail Show per-item context usage breakdown
/stats model is the only place the docs mention a cost, and they call it an estimated cost. Treat it as an estimate, not an invoice.
/stats daily and /stats monthly are the cross-session views. /stats skills is the exception: it covers the current live session only.
Cached tokens. When caching is in play, /stats shows the cached share of input, for example “10,500 (90.4%) of input tokens were served from the cache”, and only when cached tokens are being used.
/context is about the window, not money, but a window that keeps filling is what makes a long session expensive.
The status line: tokens, not dollars
Qwen Code pipes JSON to a command-mode status line. The status line docs list these fields:
model.display_name
context_window.context_window_size
context_window.used_percentage
context_window.remaining_percentage
context_window.current_usage tokens from the last API call
context_window.total_input_tokens consumed this session
context_window.total_output_tokens consumed this session
metrics.models.<id>.api total_requests, total_errors, total_latency_ms
metrics.models.<id>.tokens prompt, completion, total, cached, thoughts
metrics.files total_lines_added, total_lines_removed
The docs document no cost or price field. The config goes under the ui key in ~/.qwen/settings.json, not at the root:
{
"ui": {
"statusLine": {
"type": "command",
"command": "~/.qwen/statusline.sh",
"refreshInterval": 30
}
}
}
A script that shows session tokens, so you have a number to multiply by your own rates:
#!/bin/sh
input=$(cat)
echo "$input" | jq -r '"in " + ((.context_window.total_input_tokens // 0) | tostring)
+ " out " + ((.context_window.total_output_tokens // 0) | tostring)'
Read stdin once: the docs warn that it can only be read once, so store it first. Make the script executable with chmod +x. Commands that take longer than 5 seconds are killed and the line clears, updates are debounced to 300 ms, and changes to ui.statusLine take effect without a restart. /statusline <text> will generate a command-mode status line for you from a plain-English request.
Where usage lives
- Settings:
~/.qwen/settings.json, which holdsui.statusLine. - Usage history: behind
/stats dailyand/stats monthly. The docs I read do not say where it is stored on disk, so use/stats exportto get a copy. - Live session numbers: the status line JSON above.
What is missing
- A billed cost. The only dollar figure is the estimate in
/stats model. - A dollar field for scripts. The status line has token counts only.
- Provider rates. Qwen Code does not publish a price list, because the price depends on the provider behind it.
- Cached tokens on OAuth. The docs say caching does not happen there, so there is nothing to show.
- A team view. Nothing in the docs reports spend per developer.
Keeping a running cost visible
- Add the token status line above, and set
refreshIntervalso it updates while the agent works. - Run
/stats modelat the end of a task for the estimate. - Run
/stats export monthly --format csv --output usage.csvand keep the file, if you want your own history.
What these numbers leave out
This is all model usage. None of it records what the agent did. Qwen Code’s hooks are Claude Code’s contract, and ACP uses them to record each shell, file-edit and MCP call and check it, yolo mode included. That hook never sees the model call, so it does not price anything. To get priced spend, the cache hit rate and a loop-versus-leaf breakdown on the console, start Qwen Code with qwen-acp, which routes the model call through the ACP proxy for that launch. It only works when Qwen Code’s auth type is OpenAI, which you pick once under /auth. See the install guide and Turn on Cost X-Ray.
Frequently asked questions
How do I check token usage in Qwen Code?
Run /stats (alias /usage). It opens a usage dashboard with Session, Activity and Efficiency tabs. /stats model shows a per-model token breakdown and estimated cost, /stats tools shows per-tool call counts, and /stats daily and /stats monthly show token usage by day or month.
Can I export Qwen Code usage?
| Yes. /stats export <daily | monthly> [date | month] [--format csv | json] [--output path] writes usage statistics to CSV or JSON. |
Does the Qwen Code status line show cost?
Not as a dollar field. The JSON passed to a custom status line command has token counts, including total_input_tokens, total_output_tokens and metrics.models.
Does Qwen Code cache tokens, and can I see it?
Qwen Code’s docs say token caching happens with API key authentication, including Qwen API keys and OpenAI-compatible providers, and not with OAuth. When it is used, /stats shows how many input tokens came from the cache, as a count and a percentage.
Where to read more
- Commands:
/stats,/context,/statusline - Status line: JSON fields, config, timing
- Token caching: which auth types cache
- Qwen Code controls: hooks and approval modes
- Qwen Code install guide: the hook and the cost X-Ray
- Turn on Cost X-Ray: the proxy path across harnesses
- OpenCode cost tracking: another open-source CLI that talks to many providers
Running coding agents? ACP records each tool call its hook sees and makes the dangerous shell commands (a force-push, destructive SQL, curl | sh) wait for you. One command, free up to 5 agents:
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
irm https://agenticcontrolplane.com/install.ps1 | iex