管理账户认证,查询使用量和计费。用于:登录、登出、查询使用量、查看账单、免费套餐配额、编程计划状态、按量付费
使用量 : 使用量 : 使用量 : 使用量 : 使用量 : 免费配额、 编码计划状态和现收现付是一项面向实际任务的技能,主要用于必须安装 : 使用量 : 如果没有安装, 使用: : 运行: . node.js。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
查询 QwenCloud 使用量、免费额度、编码计划状态以及按量付费账单。
qwencloud version
如未安装,请运行:
npm install -g @qwencloud/qwencloud-cli
需 Node.js >= 18。
| 变量 | 说明 |
|---|---|
QWENCLOUD_KEYRING |
设为 plaintext、no、0、false 或 off 可禁用操作系统密钥链凭证存储功能。 |
QWENCLOUD_CREDENTIALS_DIR |
覆盖基于文件的凭证目录(默认值:~/.qwencloud/credentials)。 |
CLI 可自动检测非 TTY 环境,并安全降级处理——无需额外包装脚本。
qwencloud auth status --format json → 若返回 authenticated: true,则跳过登录,直接执行命令qwencloud auth login --init-only --format json → 提取 verification_url → 在浏览器中打开该地址qwencloud auth login --complete --format json → 持续轮询,直至收到 success 事件qwencloud auth status --format json
若返回 authenticated: true 且 token 未过期,则完全跳过登录步骤。
适用于所有环境(桌面端、无头环境、远程容器)。
第 1 步 — 初始化登录(非阻塞):
qwencloud auth login --init-only --format json
立即退出。解析 stdout 返回的 JSON 中的 events 数组:
already_authenticated → 用户已登录,可直接执行后续命令device_code → 提取 verification_url 并展示给用户在具备浏览器的桌面环境中,可为用户自动打开该 URL:
open "$VERIFICATION_URL" # macOS xdg-open "$VERIFICATION_URL" # Linux start "" "$VERIFICATION_URL" # Windows
第 2 步 — 立即启动轮询(切勿等待用户确认):
qwencloud auth login --complete --format json
解析 stdout 返回的 JSON 中的 events 数组:
success → 登录完成,继续执行后续命令expired → 设备码已过期,返回第 1 步重试error → 报告失败若 Agent 运行于 TTY 环境(例如用户终端),只需直接运行:
qwencloud auth login
CLI 将自动打开浏览器并持续轮询,直至授权完成。
--init-only 和 --complete 均输出单一 JSON 文档:
{
"events": [
{"event": "device_code", "verification_url": "...", "expires_in": 300},
{"event": "success", "authenticated": true, "user": {"aliyunId": "..."}}
]
}
支持的事件类型包括:already_authenticated、device_code、success、expired、error、pending。
--complete 前,向用户提问“您是否已完成授权?”--complete--init-only(这将生成新设备码并使旧设备码失效)所有命令均支持 --format json(输出结构化、机器可解析的 JSON,推荐作为默认格式),以及 --format text(输出简洁明了的纯文本)。
对于 Agent 场景,务必优先使用 --format json 并解析其 JSON 响应;仅当用户明确要求人类可读的纯文本时,才回退至 --format text。
请勿以编程方式解析 table 格式输出——其中包含 ANSI 控制码与 Unicode 边框字符。
qwencloud auth status — 检查当前认证状态
qwencloud auth status --format json
qwencloud auth logout — 在服务端撤销会话并清除本地凭证
qwencloud auth logout
qwencloud usage summary — 查看用量汇总(含免费额度、编码计划、按量付费)
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 输出
周期预设值:today、yesterday、week、month(默认)、last-month、quarter、year、YYYY-MM
qwencloud usage breakdown — 查看各模型用量明细
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 json
qwencloud usage free-tier — 查看免费额度详情
qwencloud usage free-tier qwencloud usage free-tier --format json
qwencloud usage payg — 查看按量付费账单详情
qwencloud usage payg qwencloud usage payg --format json
三个正交维度,可自由组合:
--model(必需)+ 日期范围 + 粒度(granularity)
模型范围:
--model — 指定单一模型(例如 qwen3.5-plus);明细查询必需指定日期范围 — 共四种模式,请根据用户描述选择最匹配的一种:
| 模式 | 适用场景 | 行为说明 |
|---|---|---|
--period YYYY-MM |
用户指定了具体月份(如“三月”、“上个月四月”) | 精确对应日历月,从月初到月末 |
--period |
用户描述的是相对时间段 | last-month 表示上一个完整自然月;month 表示本月至今;quarter 表示本自然季度至今 |
--days N |
用户说“最近 N 天” | 从今天起向前滚动 N 天,自然跨越月份边界 |
--from YYYY-MM-DD --to YYYY-MM-DD |
用户提供了明确日期,或命名的季度/区间 | 提供完全控制权,适用于其他模式无法满足的场景 |
粒度(granularity) — 决定结果分组方式,不影响时间范围:
day(默认)— 每日一行;适合识别用量突增点month — 每自然月一行;适合分析跨月趋势quarter — 每季度一行;适合同比/环比分析典型示例:
# 单一模型、单月、按日明细 qwencloud usage breakdown --model qwen3.5-plus --period 2026-03 # 单一模型、最近三个月、按月汇总 qwencloud usage breakdown --model qwen3.5-plus --days 90 --granularity month # 单一模型、特定季度、按季度汇总 qwencloud usage breakdown --model qwen3.5-plus --from 2026-01-01 --to 2026-03-31 --granularity quarter # 单一模型、本月、按日明细 qwencloud usage breakdown --model qwen3.6-plus --period month
CLI 命令在 Agent/管道环境中的默认输出格式为 JSON(auto 模式:TTY → table,管道 → json)。JSON 是 Agent 的主要输出格式——请始终显式传入 --format json,解析结构化响应后,再向用户呈现人类可读的摘要。
--format json)qwencloud usage summary --period month --format 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" }
}
}
--format text)qwencloud usage summary --period month --format text
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
当使用 --format json(Agent 推荐)时:
--- 明确分隔当使用 --format text 时:
--- 明确分隔绝对禁止的操作:
✅ 正确示例(JSON 模式):
您在四月的 QwenCloud 使用情况如下: **免费额度**:qwen3.6-plus 剩余 85%(850K / 1M tokens),wan2.6-t2i 剩余 76%(38 / 50 images)。 **编码计划(PRO)**:本月已使用 8%(82.5K / 90K 请求)。 **按量付费**:总计 $0.51 — 其中 qwen3.6-plus $0.38,qwen-plus $0.13。 --- **💡 分析**:您的 qwen3.6-plus 免费额度尚有 85% 剩余...
✅ 正确示例(Text 模式):
[CLI text 输出 - 完全原样] --- **💡 分析**:您的 qwen3.6-plus 免费额度尚有 85% 剩余...
❌ 错误示例:
这是您的用量信息: - qwen3.6-plus:剩余 850K tokens(剩余 85%)
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 1 | 通用错误或使用错误 |
| 2 | 认证错误 |
| 3 | 网络错误 |
| 4 | 配置错误 |
| 130 | 被中断 |
当用户明确要求检查 CLI 更新(例如:“检查 CLI 更新”、“检查 CLI 版本”、“是否有新版本 CLI”)时:
qwencloud version --checkQwenCloud CLI 原生支持更新通知机制;本能力无需额外处理 stderr 信号。
--model 参数为必需项:与旧版 Python 实现不同,CLI 要求 breakdown 必须指定 --model。如需查询所有模型用量,请改用 qwencloud usage summary。相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 133.7万人学习
共49课时 | 82.4万人学习