qwencloud-usage
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQwenCloud Usage
QwenCloud 使用指南
Query QwenCloud usage, free tier quota, coding plan status, and pay-as-you-go billing.
查询QwenCloud的使用情况、免费额度、编码计划状态以及按需付费账单。
Prerequisites
前提条件
- QwenCloud CLI must be installed. Verify with:
bash
qwencloud versionIf not installed, run:
bash
npm install -g @qwencloud/qwencloud-cliNode.js >= 18 required.
- Authentication: No configuration needed on first use. The CLI handles non-TTY detection and safe login automatically (see Authentication Flow below).
- QwenCloud CLI 必须安装。可通过以下命令验证:
bash
qwencloud version如果未安装,运行:
bash
npm install -g @qwencloud/qwencloud-cliNode.js >= 18 为必要条件。
- 认证:首次使用无需配置。CLI会自动检测非TTY环境并安全完成登录(详见下方的认证流程)。
Environment Variables
环境变量
| Variable | Description |
|---|---|
| Set to |
| Override file-based credential directory (default: |
| 变量名 | 描述 |
|---|---|
| 设置为 |
| 覆盖基于文件的凭证目录(默认: |
Authentication Flow (for Agents)
认证流程(适用于Agent)
The CLI auto-detects non-TTY environments and degrades safely — no wrapper script needed.
CLI会自动检测非TTY环境并安全降级处理 — 无需包装脚本。
TL;DR — 3-step auth path
快速概览 — 三步认证路径
- →
qwencloud auth status --format json→ skip to commandsauthenticated: true - → extract
qwencloud auth login --init-only --format json→ open in browserverification_url - → poll until
qwencloud auth login --complete --format jsoneventsuccess
- →
qwencloud auth status --format json→ 直接执行后续命令authenticated: true - → 提取
qwencloud auth login --init-only --format json→ 在浏览器中打开verification_url - → 轮询直到出现
qwencloud auth login --complete --format json事件success
Quick check: already logged in?
快速检查:是否已登录?
bash
qwencloud auth status --format jsonIf and token is not expired, skip login entirely.
authenticated: truebash
qwencloud auth status --format json如果返回 且令牌未过期,可直接跳过登录步骤。
authenticated: trueRecommended: Two-phase login
推荐:两阶段登录
Works in all environments (desktop, headless, remote container).
Step 1 — Initialize login (non-blocking):
bash
qwencloud auth login --init-only --format jsonExits immediately. Parse the stdout JSON array:
events- → user is logged in, skip to commands
already_authenticated - → extract
device_codeand present it to the userverification_url
On desktop environments with a browser, open the URL for the user:
bash
open "$VERIFICATION_URL" # macOS
xdg-open "$VERIFICATION_URL" # Linux
start "" "$VERIFICATION_URL" # WindowsStep 2 — IMMEDIATELY start polling (do NOT wait for user confirmation):
bash
qwencloud auth login --complete --format jsonParse the stdout JSON array:
events- → login complete, proceed to commands
success - → device code expired, go back to Step 1
expired - → report failure
error
适用于所有环境(桌面、无头环境、远程容器)。
步骤1 — 初始化登录(非阻塞):
bash
qwencloud auth login --init-only --format json命令立即退出。解析标准输出的JSON 数组:
events- → 用户已登录,直接执行后续命令
already_authenticated - → 提取
device_code并展示给用户verification_url
在带有浏览器的桌面环境中,可为用户自动打开该链接:
bash
open "$VERIFICATION_URL" # macOS
xdg-open "$VERIFICATION_URL" # Linux
start "" "$VERIFICATION_URL" # Windows步骤2 — 立即启动轮询(请勿等待用户确认):
bash
qwencloud auth login --complete --format json解析标准输出的JSON 数组:
events- → 登录完成,执行后续命令
success - → 设备代码已过期,返回步骤1重新操作
expired - → 报告登录失败
error
TTY environments (interactive terminal)
TTY环境(交互式终端)
If the agent is running in a TTY (e.g., user's terminal), simply run:
bash
qwencloud auth loginThe CLI will automatically open the browser and poll until authorization completes.
如果Agent运行在TTY环境中(例如用户的终端),只需运行:
bash
qwencloud auth loginCLI会自动打开浏览器并轮询直到授权完成。
JSON event structure
JSON事件结构
Both and output a single JSON document:
--init-only--completejson
{
"events": [
{"event": "device_code", "verification_url": "...", "expires_in": 300},
{"event": "success", "authenticated": true, "user": {"aliyunId": "..."}}
]
}Event types: , , , , , .
already_authenticateddevice_codesuccessexpirederrorpending--init-only--completejson
{
"events": [
{"event": "device_code", "verification_url": "...", "expires_in": 300},
{"event": "success", "authenticated": true, "user": {"aliyunId": "..."}}
]
}事件类型包括:、、、、、。
already_authenticateddevice_codesuccessexpirederrorpendingNEVER:
禁止操作:
- ❌ Ask the user "Have you completed authorization?" before running
--complete - ❌ Wait for user confirmation before polling — run immediately after presenting the URL
--complete - ❌ Re-run without completing (this creates a new device code and invalidates the previous one)
--init-only
- ❌ 在运行 前询问用户“是否已完成授权?”
--complete - ❌ 在用户确认后才启动轮询 — 展示链接后立即运行
--complete - ❌ 在未完成当前流程的情况下重新运行 (这会生成新的设备代码并使之前的代码失效)
--init-only
Usage
使用方法
All commands support for structured, machine-parseable output (recommended default), and for clean plaintext output.
--format json--format textFor agent use, always prefer and parse the JSON response. Only fall back to when the user explicitly requests human-readable plaintext.
--format json--format textNever parse format programmatically — it contains ANSI codes and Unicode borders.
table所有命令均支持 以输出结构化、可机器解析的内容(推荐默认使用),同时支持 以输出简洁的纯文本内容。
--format json--format text对于Agent使用场景,始终优先使用 并解析JSON响应。仅当用户明确要求人类可读的纯文本时,才回退到 。
--format json--format text请勿以编程方式解析 格式 — 该格式包含ANSI代码和Unicode边框。
tableAuth Commands
认证命令
qwencloud auth statusbash
qwencloud auth status --format jsonqwencloud auth logoutbash
qwencloud auth logoutqwencloud auth statusbash
qwencloud auth status --format jsonqwencloud auth logoutbash
qwencloud auth logoutUsage Commands
使用情况查询命令
qwencloud usage summarybash
qwencloud usage summary # Current month
qwencloud usage summary --period last-month # Last month
qwencloud usage summary --from 2026-03-01 --to 2026-03-31
qwencloud usage summary --format json # JSON outputPeriod presets: , , , (default), , , ,
todayyesterdayweekmonthlast-monthquarteryearYYYY-MMqwencloud usage breakdownbash
qwencloud usage breakdown --model qwen3.6-plus --days 7
qwencloud usage breakdown --model qwen3.5-plus --period 2026-03
qwencloud usage breakdown --model qwen-plus --period 2026-03 --granularity month
qwencloud usage breakdown --model qwen3.6-plus --format jsonqwencloud usage free-tierbash
qwencloud usage free-tier
qwencloud usage free-tier --format jsonqwencloud usage paygbash
qwencloud usage payg
qwencloud usage payg --format jsonqwencloud usage summarybash
qwencloud usage summary # 当前月份
qwencloud usage summary --period last-month # 上月
qwencloud usage summary --from 2026-03-01 --to 2026-03-31
qwencloud usage summary --format json # JSON输出周期预设值:、、、(默认)、、、、
todayyesterdayweekmonthlast-monthquarteryearYYYY-MMqwencloud usage breakdownbash
qwencloud usage breakdown --model qwen3.6-plus --days 7
qwencloud usage breakdown --model qwen3.5-plus --period 2026-03
qwencloud usage breakdown --model qwen-plus --period 2026-03 --granularity month
qwencloud usage breakdown --model qwen3.6-plus --format jsonqwencloud usage free-tierbash
qwencloud usage free-tier
qwencloud usage free-tier --format jsonqwencloud usage paygbash
qwencloud usage payg
qwencloud usage payg --format jsonBreakdown Parameters: How to Think About Them
明细参数:使用思路
Three independent dimensions — combine them freely:
--modelModel scope:
- — single model (e.g.
--model <id>); required for breakdownqwen3.5-plus
Date range — three patterns, pick by how the user described the period:
| Pattern | When to use | How it works |
|---|---|---|
| User names a specific month ("March", "last April") | Exact calendar month, start to end |
| User describes a relative period | |
| User says "last N days" | Rolling window backwards from today, crosses month boundaries naturally |
| User gives explicit dates or a named quarter/range | Full control, use when other patterns don't fit |
Granularity — determines the grouping of results, not the range:
- (default) — one row per day; good for spotting usage spikes
day - — one row per calendar month; good for multi-month trends
month - — one row per quarter; good for Q-over-Q comparison
quarter
Classic examples:
bash
undefined三个独立维度 — 可自由组合:
--model模型范围:
- — 指定单个模型(例如
--model <id>);查询明细时必填qwen3.5-plus
日期范围 — 三种模式,根据用户描述的周期选择:
| 模式 | 使用场景 | 工作原理 |
|---|---|---|
| 用户指定具体月份(“三月”、“去年四月”) | 精确的日历月份,从月初到月末 |
| 用户描述相对周期 | |
| 用户提及“过去N天” | 从今天开始向前滚动的时间窗口,自然跨越月份边界 |
| 用户给出明确日期或指定季度/范围 | 完全可控,当其他模式不适用时使用 |
粒度 — 决定结果的分组方式,而非时间范围:
- (默认) — 按天分组;便于发现使用量峰值
day - — 按日历月分组;便于查看多月趋势
month - — 按季度分组;便于季度间对比
quarter
经典示例:
bash
undefinedSingle model, single month, daily detail
单个模型、单个月份、每日明细
qwencloud usage breakdown --model qwen3.5-plus --period 2026-03
qwencloud usage breakdown --model qwen3.5-plus --period 2026-03
Single model, last 3 months, monthly summary
单个模型、过去3个月、月度汇总
qwencloud usage breakdown --model qwen3.5-plus --days 90 --granularity month
qwencloud usage breakdown --model qwen3.5-plus --days 90 --granularity month
Single model, specific quarter, quarterly rollup
单个模型、指定季度、季度汇总
qwencloud usage breakdown --model qwen3.5-plus --from 2026-01-01 --to 2026-03-31 --granularity quarter
qwencloud usage breakdown --model qwen3.5-plus --from 2026-01-01 --to 2026-03-31 --granularity quarter
Single model, this month, daily breakdown
单个模型、当前月份、每日明细
qwencloud usage breakdown --model qwen3.6-plus --period month
undefinedqwencloud usage breakdown --model qwen3.6-plus --period month
undefinedOutput and Agent Display Rules
输出与Agent展示规则
CLI commands return JSON by default in agent/pipe environments ( format: TTY → table, pipe → json).
JSON is the primary output mode for agents — always pass explicitly, parse the structured response, then present a human-readable summary to the user.
auto--format json在Agent/管道环境中,CLI命令默认返回JSON(格式:TTY环境返回表格,管道环境返回JSON)。
JSON是Agent的主要输出模式 — 始终显式传递 ,解析结构化响应后,再向用户展示人类可读的摘要。
auto--format jsonJSON output example (--format json
)
--format jsonJSON输出示例(--format json
)
--format jsonbash
qwencloud usage summary --period month --format jsonReturns structured JSON with three sections:
json
{
"period": { "from": "2026-04-01", "to": "2026-04-24" },
"free_tier": [
{ "model_id": "qwen3.6-plus", "quota": { "remaining": 850000, "total": 1000000, "unit": "tokens", "used_pct": 15 } }
],
"coding_plan": {
"subscribed": true,
"plan": "PRO",
"windows": {
"per_5h": { "remaining": 4800, "total": 6000, "used_pct": 20 },
"weekly": { "remaining": 38200, "total": 45000, "used_pct": 15 },
"monthly": { "remaining": 82500, "total": 90000, "used_pct": 8 }
}
},
"pay_as_you_go": {
"models": [
{ "model_id": "qwen3.6-plus", "usage": { "tokens_total": 480000 }, "cost": 0.38, "currency": "USD" },
{ "model_id": "qwen-plus", "usage": { "tokens_total": 460000 }, "cost": 0.13, "currency": "USD" }
],
"total": { "cost": 0.51, "currency": "USD" }
}
}bash
qwencloud usage summary --period month --format json返回包含三个部分的结构化JSON:
json
{
"period": { "from": "2026-04-01", "to": "2026-04-24" },
"free_tier": [
{ "model_id": "qwen3.6-plus", "quota": { "remaining": 850000, "total": 1000000, "unit": "tokens", "used_pct": 15 } }
],
"coding_plan": {
"subscribed": true,
"plan": "PRO",
"windows": {
"per_5h": { "remaining": 4800, "total": 6000, "used_pct": 20 },
"weekly": { "remaining": 38200, "total": 45000, "used_pct": 15 },
"monthly": { "remaining": 82500, "total": 90000, "used_pct": 8 }
}
},
"pay_as_you_go": {
"models": [
{ "model_id": "qwen3.6-plus", "usage": { "tokens_total": 480000 }, "cost": 0.38, "currency": "USD" },
{ "model_id": "qwen-plus", "usage": { "tokens_total": 460000 }, "cost": 0.13, "currency": "USD" }
],
"total": { "cost": 0.51, "currency": "USD" }
}
}Text output example (--format text
)
--format text文本输出示例(--format text
)
--format textbash
qwencloud usage summary --period month --format textplaintext
Usage Summary · 2026-04-10
-- Free Tier Quota -------------------------------------------------------
Model Remaining Total Progress
qwen3.6-plus 850K tokens 1M tokens 85% left
wan2.6-t2i 38 images 50 images 76% left
--------------------------------------------------------------------------
-- Coding Plan · PRO Plan ------------------------------------------------
Window Remaining Total Progress
Per 5 hours 4.8K req 6K req 20% used
This week 38.2K req 45K req 15% used
This month 82.5K req 90K req 8% used
--------------------------------------------------------------------------
-- Pay-as-you-go · 2026-04-01 → 2026-04-10 -------------------------------
Model Usage Cost
qwen3.6-plus 480K tok $0.38
qwen-plus 460K tok $0.13
--------------------------------------------------------------------------
Total — $0.51bash
qwencloud usage summary --period month --format textplaintext
Usage Summary · 2026-04-10
-- Free Tier Quota -------------------------------------------------------
Model Remaining Total Progress
qwen3.6-plus 850K tokens 1M tokens 85% left
wan2.6-t2i 38 images 50 images 76% left
--------------------------------------------------------------------------
-- Coding Plan · PRO Plan ------------------------------------------------
Window Remaining Total Progress
Per 5 hours 4.8K req 6K req 20% used
This week 38.2K req 45K req 15% used
This month 82.5K req 90K req 8% used
--------------------------------------------------------------------------
-- Pay-as-you-go · 2026-04-01 → 2026-04-10 -------------------------------
Model Usage Cost
qwen3.6-plus 480K tok $0.38
qwen-plus 460K tok $0.13
--------------------------------------------------------------------------
Total — $0.51⚠️ CRITICAL: How to present output to the user
⚠️ 重要提示:如何向用户展示输出
When using (recommended for agents):
--format json- Parse the JSON and extract the relevant data for the user's question
- Present a human-readable summary — do not dump raw JSON to the user
- Add analysis AFTER the summary — clearly separated with
---
When using :
--format text- Display CLI output EXACTLY AS-IS — no modification, no reformatting
- Preserve all formatting — alignment, spacing, progress bars, separators
- Add analysis AFTER output only — clearly separated with
---
NEVER:
- ❌ Dump raw JSON to the user without interpretation
- ❌ Reformat or summarize text/table output
- ❌ Add prefixes like "Here's your usage:"
- ❌ Convert text/table output to bullet points
✅ CORRECT (JSON mode):
Your QwenCloud usage for April:
**Free Tier**: qwen3.6-plus has 85% remaining (850K / 1M tokens), wan2.6-t2i has 76% remaining (38 / 50 images).
**Coding Plan (PRO)**: 8% used this month (82.5K / 90K requests).
**Pay-as-you-go**: $0.51 total — qwen3.6-plus $0.38, qwen-plus $0.13.
---
**💡 Analysis**: Your qwen3.6-plus free tier is 85% remaining...✅ CORRECT (Text mode):
[CLI text output - exactly as-is]
---
**💡 Analysis**: Your qwen3.6-plus free tier is 85% remaining...❌ WRONG:
Here's your usage:
- qwen3.6-plus: 850K tokens remaining (85% left)使用 时(Agent推荐模式):
--format json- 解析JSON 并提取与用户问题相关的数据
- 展示人类可读的摘要 — 请勿直接向用户输出原始JSON
- 在摘要后添加分析 — 用 清晰分隔
---
使用 时:
--format text- 完全原样展示CLI输出 — 不修改、不重新格式化
- 保留所有格式 — 对齐方式、间距、进度条、分隔线
- 仅在输出后添加分析 — 用 清晰分隔
---
禁止操作:
- ❌ 不做解释直接向用户输出原始JSON
- ❌ 重新格式化或汇总文本/表格输出
- ❌ 添加类似“这是您的使用情况:”的前缀
- ❌ 将文本/表格输出转换为项目符号列表
✅ 正确示例(JSON模式):
您的QwenCloud四月使用情况:
**免费额度**:qwen3.6-plus剩余85%(85万/100万 tokens),wan2.6-t2i剩余76%(38/50张图片)。
**编码计划(PRO)**:本月已使用8%(8.25万/9万次请求)。
**按需付费**:总计0.51美元 — qwen3.6-plus花费0.38美元,qwen-plus花费0.13美元。
---
**💡 分析**:您的qwen3.6-plus免费额度剩余85%...✅ 正确示例(文本模式):
[CLI文本输出 — 完全原样]
---
**💡 分析**:您的qwen3.6-plus免费额度剩余85%...❌ 错误示例:
这是您的使用情况:
- qwen3.6-plus:剩余85万 tokens(85%)Exit Codes
退出码
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General/usage error |
| 2 | Authentication error |
| 3 | Network error |
| 4 | Configuration error |
| 130 | Interrupted |
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 1 | 常规/使用错误 |
| 2 | 认证错误 |
| 3 | 网络错误 |
| 4 | 配置错误 |
| 130 | 操作中断 |
CLI Update Check
CLI版本检查
When the user explicitly asks to check for cli updates (e.g. "check for cli updates", "check cli version", "is there a new version cli"):
- Run:
qwencloud version --check - Report the result.
The QwenCloud CLI handles update notifications natively; no additional stderr signal handling is required in this skill.
当用户明确要求检查CLI更新时(例如“检查CLI更新”、“查看CLI版本”、“CLI有新版本吗”):
- 运行:
qwencloud version --check - 向用户报告结果。
QwenCloud CLI原生支持更新通知;本技能无需额外处理stderr信号。
Implementation Notes
实现说明
- Pay-as-you-go: API returns total usage only (no input/output split)
- Coding Plan: Aggregate request counts at plan level (no per-model breakdown)
- logout: Revokes server-side session and clears local credentials (keychain + file). Server-side call is best-effort — local logout always succeeds.
- Authentication: Uses OAuth 2.0 Device Authorization Grant with PKCE. Credentials stored in OS keychain when available, with encrypted file fallback.
- breakdown --model is required: Unlike the previous Python implementation, the CLI requires for breakdown. To query all models' usage, use
--modelinstead.qwencloud usage summary
- 按需付费:API仅返回总使用量(不区分输入/输出)
- 编码计划:按计划级别汇总请求次数(无按模型细分)
- logout:服务器端吊销会话并清除本地凭证(密钥链+文件)。服务器端调用为尽力而为 — 本地登出始终成功。
- 认证:使用带有PKCE的OAuth 2.0设备授权流程。凭证优先存储在操作系统密钥链中, fallback到加密文件存储。
- breakdown --model为必填项:与之前的Python实现不同,CLI查询明细时必须指定。如需查询所有模型的使用情况,请使用
--model。qwencloud usage summary