mcpField
Q
qianwen-usage

qianwen-usage

github.com/qianwen-ai云与 DevOps1155.5k 次安装3 周前更新
代码仓库

关于 qianwen-usage

qianwen-usage 是通过 QianWen CLI 查询账户认证、用量、额度、账单和订阅的 Agent Skill,兼顾汇总统计与逐请求诊断。

主要功能

  1. 01检查认证状态并登录
  2. 02查看用量、额度和模型成本
  3. 03检查请求日志与失败记录
  4. 04查看账单和订阅详情

适用场景

  1. 01检查免费额度余量
  2. 02比较一段时间内的模型用量
  3. 03排查失败请求和延迟
  4. 04查看账单与订阅状态

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/qianwen-ai/qianwen-ai --skill qianwen-usage

安装后在 Claude Code 中输入/qianwen-usage确认已加载。

详细介绍

QianWenAI 使用情况

QianWenAI 账户、使用情况、账单和订阅的统一入口:认证状态、使用情况摘要、免费层级配额、Token Plan、按量付费、账单摘要、模型费用明细、订阅状态、订单历史、团队席位和 PAYG 支出限额。

前提条件

  • 必须安装 QianWen CLI。运行以下命令验证:
qianwen version

如果尚未安装,请运行:

npm install -g @qianwenai/qianwen-cli

需要 Node.js >= 18。

  • 身份验证:首次使用无需配置。CLI 会自动处理非 TTY 检测和安全登录(见下文“身份验证流程”)。

执行基准

本技能中的每条命令都适用以下规则:

  • CLI 版本基准:1.3.0。 执行前,检查 qianwen version。如果已安装的版本低于 1.3.0,请勿调用可能不存在的命令(尤其是 billing 和 subscription 命令组);说明已安装的 CLI 版本早于基准,并等待用户确认升级后再继续。(这是每次运行前都要执行的检查,与下文“CLI 更新检查”部分不同;后者仅在用户明确询问 CLI 更新时适用。)
  • 仅限白名单。 只能运行本文件中说明的命令和参数。切勿拼接任意 Shell 字符串,或将未经检查的用户输入传入命令行。
  • 统一结果状态。 将每条命令的结果映射为以下五种状态之一:success / partial / empty / confirmation_required / error。切勿用模拟数据填补缺失或失败的结果——如实报告实际情况。
  • 仅使用 CLI 输出中的 URL。 只能提供 CLI 返回的 URL(例如 verification_url)。切勿根据名称或猜测编造 URL。

身份验证流程(适用于 Agent)

CLI 会自动检测非 TTY 环境并安全降级,无需包装脚本。

简要说明 — 3 步身份验证流程
  1. qianwen auth status --format json → authenticated: true → 跳过登录,直接执行命令
  2. qianwen auth login --init-only --format json → 提取 verification_url → 在浏览器中打开
  3. qianwen auth login --complete --format json → 持续轮询,直到出现 success 事件
快速检查:是否已登录?
qianwen auth status --format json

如果 authenticated: true 且令牌未过期,则完全跳过登录。

推荐:两阶段登录

适用于所有环境(桌面、无头环境、远程容器)。

第 1 步 — 初始化登录(非阻塞):

qianwen auth login --init-only --format json

命令会立即退出。解析标准输出中的 JSON events 数组:

  • already_authenticated → 用户已登录,跳过登录,直接执行命令
  • device_code → 提取 verification_url 并提供给用户

在带有浏览器的桌面环境中,为用户打开 URL:

open "$VERIFICATION_URL"          # macOS
xdg-open "$VERIFICATION_URL"      # Linux
start "" "$VERIFICATION_URL"      # Windows

第 2 步 — 立即开始轮询(不要等待用户确认):

qianwen auth login --complete --format json

解析标准输出中的 JSON events 数组:

  • success → 登录完成,继续执行命令
  • expired → 设备码已过期,返回第 1 步
  • error → 报告失败
TTY 环境(交互式终端)

如果 Agent 在 TTY 中运行(例如用户的终端),只需运行:

qianwen auth login

CLI 会自动打开浏览器并持续轮询,直到授权完成。

JSON 事件结构

--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 之前询问用户“您是否已完成授权?”
  • ❌ 在轮询前等待用户确认——提供 URL 后立即运行 --complete
  • ❌ 未完成登录就重新运行 --init-only(这会创建新的设备码,并使之前的设备码失效)

用法

所有命令都支持 --format json,用于输出结构化、可供机器解析的内容(推荐作为默认格式);也支持 --format text,用于输出清晰的纯文本。

供 Agent 使用时,始终优先选择 --format json,并解析 JSON 响应。仅当用户明确要求输出便于人类阅读的纯文本时,才回退到 --format text。

切勿以编程方式解析 table 格式——其中包含 ANSI 代码和 Unicode 边框。

身份验证命令

qianwen auth status — 检查当前身份验证状态

qianwen auth status --format json

qianwen auth logout — 在服务端撤销会话并清除本地凭据

⚠️ 需要确认:注销会破坏当前会话。始终先征求用户确认(confirmation_required 状态);仅在用户明确确认后运行命令。

qianwen auth logout
用量命令

qianwen usage summary — 查看用量摘要(免费额度、Token Plan、按量付费)

qianwen usage summary                      # Current month
qianwen usage summary --period last-month  # Last month
qianwen usage summary --from 2026-03-01 --to 2026-03-31
qianwen usage summary --format json        # JSON output

周期预设:today、yesterday、week、month(默认)、last-month、quarter、year、YYYY-MM

qianwen usage breakdown — 查看模型用量明细

qianwen usage breakdown --model qwen3.6-plus --days 7
qianwen usage breakdown --model qwen3.5-plus --period 2026-03
qianwen usage breakdown --model qwen-plus --period 2026-03 --granularity month
qianwen usage breakdown --model qwen3.6-plus --format json

注意:明细仅显示按量付费的消耗,不包含免费额度用量;如需查看当前额度状态,请使用 usage free-tier。

qianwen usage free-tier — 查看免费额度详情

qianwen usage free-tier
qianwen usage free-tier --format json

qianwen usage payg — 查看按量付费用量及各模型的费用

显示当前周期的按量付费消耗。如需查看历史计费周期,请使用 qianwen billing summary(见下文的计费命令)。

qianwen usage payg
qianwen usage payg --format json
qianwen usage payg --period month --format json   # Recommended: current month PAYG

qianwen usage logs — 浏览分页调用日志(逐请求历史记录),可按时间、模型和状态筛选

适用于请求级别的问题,例如“哪些调用失败了?”、“显示 4xx/5xx 错误”、“这些请求耗时多久?”、“我最近调用了哪些模型?”、“查找此请求 ID”。这与 usage summary/breakdown(Token/费用汇总)不同——失败诊断、延迟和调用历史相关问题应使用此命令,而不是 summary/breakdown。

qianwen usage logs --period 7d --format json
qianwen usage logs --period 24h --status 4xx --status 5xx --format json   # recent client/server errors
qianwen usage logs --model qwen-plus --page 2 --page-size 50 --format json
qianwen usage logs --from 2026-07-25 --to 2026-08-07 --format json         # explicit range (must be ≤ 14 days)
qianwen usage logs --request-id 8c81644f-... --format json                # exact lookup

选项:

  • --from / --to — 日期范围(YYYY-MM-DD 或 RFC3339)
  • --period <preset> — 1h、24h、7d、today、yesterday、week、month、……(与 usage summary 使用相同的预设系列)。⚠️ 解析后的范围必须 ≤ 14 天。 month(月中之后)、last-month、quarter 和 year 等预设会超出限制并返回 INVALID_ARGUMENT。建议使用较短的预设:1h、24h、7d、today、yesterday、week。
  • --model <id> — 按模型筛选;可重复(传入多个 --model 标志以包含多个模型)
  • --status <type> — 状态筛选:0(已取消)、2xx(成功)、4xx(客户端错误)、5xx(服务端错误);可重复
  • --request-id <id> — 精确匹配请求 ID;设置后将忽略所有其他筛选条件
  • --page <n>(默认值为 1)/ --page-size <n>(1..100)

⚠️ 14 天范围限制:解析后的时间范围必须 ≤ 14 天。任何超过 14 天的范围(无论通过 --from/--to 还是较长的 --period 指定)都会返回 INVALID_ARGUMENT(退出码 4,"Time range cannot be longer than 14 days.")。如需扫描更长的历史记录,请通过连续调用 --from/--to,逐步移动不超过 14 天的时间窗口。这与可接受多月范围的 usage summary/breakdown 不同。

分页:结果采用分页方式。要遍历某个时间窗口内的全部历史记录,请从 --page 1 --page-size 100 开始,然后在 page × pageSize < totalCount 时持续递增 --page,直到检索完全部 totalCount 条记录。

JSON 结构(根据 CLI 源码:顶层包含 totalCount / page / pageSize / period / items;在 items[] 中,errorCode 仅在调用失败时存在,usages 包含每个请求的 Token/字符消耗,失败或取消的调用中该字段为空):

{
  "totalCount": 4,
  "page": 1,
  "pageSize": 20,
  "period": { "from": "2026-07-25", "to": "2026-08-07" },
  "items": [
    { "requestId": "8c81644f-...", "model": "wan3.0-video", "statusCode": 403, "durationMs": 548, "errorCode": "Forbidden.NoPermission", "usages": [] },
    { "requestId": "8e3a2c02-...", "model": "qwen3.8-max", "statusCode": 200, "durationMs": 956, "usages": [ { "type": "tokens", "total": 1820 } ] }
  ]
}

period.from / period.to 会回显解析后的时间窗口:日历预设和显式指定的 --from/--to 日期会显示为 YYYY-MM-DD,而滚动预设(1h、24h、7d)会显示为 RFC3339 时间戳。没有匹配的调用时,CLI 会返回 totalCount: 0 和空的 items: []——应将其映射为 empty 状态(而不是错误)。

字段:requestId(用于关联服务端跟踪记录)、model、statusCode(HTTP 风格状态码——2xx 表示成功、4xx 表示客户端错误、5xx 表示服务端错误、0 表示已取消)、durationMs(调用延迟)、errorCode(失败原因,仅在非 2xx 时存在)、usages(每个请求的消耗;失败或取消的调用中为空)。使用 statusCode + errorCode 进行失败排查,使用 durationMs 分析延迟。

拆分参数:如何理解它们

三个相互独立的维度——可自由组合:

--model(必填)+ 日期范围 + 粒度

模型范围:

  • --model <id> — 单个模型(例如 qwen3.5-plus);拆分查询必填

日期范围 — 三种模式,根据用户描述的时间段选择:

模式使用时机工作方式
--period YYYY-MM用户指定某个月(“三月”“去年四月”)精确的日历月,从月初到月末
--period <preset>用户描述相对时间段last-month = 上一个完整月份;month = 本月至今;quarter = 本日历季度至今
--days N用户说“过去 N 天”从今天起向前滚动计算,自然跨越月份边界
--from YYYY-MM-DD --to YYYY-MM-DD用户提供明确日期或指定季度/范围完全自定义,其他模式不适用时使用

粒度 — 决定结果的分组方式,而非日期范围:

  • day(默认)— 每天一行;适合发现用量峰值
  • month — 每个日历月一行;适合查看多月趋势
  • quarter — 每个季度一行;适合进行环比比较

典型示例:

# Single model, single month, daily detail
qianwen usage breakdown --model qwen3.5-plus --period 2026-03

# Single model, last 3 months, monthly summary
qianwen usage breakdown --model qwen3.5-plus --days 90 --granularity month

# Single model, specific quarter, quarterly rollup
qianwen usage breakdown --model qwen3.5-plus --from 2026-01-01 --to 2026-03-31 --granularity quarter

# Single model, this month, daily breakdown
qianwen usage breakdown --model qwen3.6-plus --period month
账单命令

qianwen billing summary — 指定包含起止月份的 YYYY-MM 账期窗口内的账单总额

qianwen billing summary --from 2026-05 --to 2026-07 --format json
qianwen billing summary --charge-type payg --format json   # payg | subscription | all (default)

cycles 按顺序涵盖 --from..--to 窗口中的每个月,没有缺漏。每个账期都包含 billingCycle、aftertaxAmount 和 settled 标志。chargeType 是内部值 — all、订阅对应的 prepaid、按量付费对应的 postpaid;金额为十进制字符串。

如果 JSON 输出中包含 settled,则表示该账期是否存在账单数据(true = 存在,false = 不存在)。当值为 true 时,应将 aftertaxAmount 作为实际金额报告(包括 ¥0)。

{
  "period": { "from": "2026-05", "to": "2026-08" },
  "chargeType": "all",
  "currency": "CNY",
  "cycles": [
    { "billingCycle": "202605", "aftertaxAmount": null, "settled": false },
    { "billingCycle": "202606", "aftertaxAmount": "3.710000", "settled": true },
    { "billingCycle": "202607", "aftertaxAmount": null, "settled": false },
    { "billingCycle": "202608", "aftertaxAmount": "0.000000", "settled": true }
  ],
  "totals": { "aftertaxAmount": "3.71" }
}

qianwen billing breakdown — 按模型(或 API 密钥)统计消费 Top-N

qianwen billing breakdown --period month --group-by model --top 10 --format json
qianwen billing breakdown --group-by api-key --top 10 --format json

选项:--group-by model|api-key(默认 model)、--top <n>(默认 10,最大 100)、--granularity day|month(默认 month)、--charge-type all|subscription|payg,以及 --period / --from / --to 日期范围。按天粒度要求范围 ≤ 31 天;按月粒度要求范围 ≤ 12 个月。

单个周期查询的 JSON 结构(根据 CLI 源码,为原始 ConsumeBreakdown 对象):

{
  "groupBy": "model",
  "period": { "from": "2026-07-01", "to": "2026-07-29" },
  "chargeType": "all",
  "rows": [
    { "groupKey": "qwen3.6-plus", "groupLabel": "qwen3.6-plus", "amount": "5.20" },
    { "groupKey": "qwen-plus", "groupLabel": "qwen-plus", "amount": "1.80" }
  ],
  "totalRows": 12,
  "totalAmount": "9.80",
  "currency": "CNY"
}

当范围跨越多个周期(例如数个月)时,JSON 会按周期切片:{ "groupBy", "dateRange": { "from", "to" }, "granularity", "chargeType", "slices": [ { "period", "rows", "totalAmount" } ], "currency" }。

qianwen billing limit — 按量付费消费限额和提醒配置

qianwen billing limit --format json

只读 — 此命令仅显示 PAYG 消费限额;CLI 不支持修改该限额。需要更改时,请引导用户前往控制台。

JSON 结构(根据 CLI 源码,为原始 UsageLimit 对象;未设置限额时,limitAmount 可能为 null):

{
  "status": "normal",
  "limitAmount": "500.00",
  "currency": "CNY",
  "alertThreshold": "80"
}

status 的取值:normal / active / exceeded / warning / unknown。

订阅命令

qianwen subscription status — 汇总各套餐的订阅状态

qianwen subscription status --format json
qianwen subscription status --plan token --format json

JSON 结构(根据 CLI 源码:包含 SubscriptionStatus 字段及 diagnostics;recentOrders[].orderType 和 .status 已映射为 Purchase / Paid 等显示标签;可空字段可能为 null,数组可能为空):

{
  "isGray": false,
  "plan": "Token Plan Team Edition",
  "period": { "start": "2026-07-01", "end": "2026-08-01" },
  "quota": { "remaining": 21000, "total": 25000, "usedPct": 16 },
  "autoRenew": true,
  "renewable": true,
  "remainingDays": 3,
  "seatTiers": [
    { "specType": "standard", "seats": 2, "totalCredits": 50000, "remainingCredits": 42000, "usedPct": 16, "nextCycleFlushTime": "2026-08-01" }
  ],
  "creditPacks": [
    { "instanceId": "cp-xxxxxxxx", "totalCredits": 10000, "remainingCredits": 8000, "expiresAt": "2026-12-31" }
  ],
  "recentOrders": [
    { "orderId": "20260701xxxx", "orderType": "Purchase", "orderTime": "2026-07-01 10:00:00", "amount": "199.00", "status": "Paid" }
  ],
  "diagnostics": []
}

状态由多个子调用的结果组成;部分调用失败时会显示在 diagnostics 中(每个条目包含:api、errorCode、errorMessage)——此类结果应映射为 partial 状态。如果 data 整体为 null,命令将以代码 1 退出(error 状态)。

⚠️ 只有 autoRenew 为 true 时,nextCycleFlushTime 才表示配额重置时间。 对于所有席位层级,当 autoRenew 为 false(明确关闭自动续订)时,CLI 返回的 nextCycleFlushTime: null;因此,非 null 的值可解读为“额度将在该日期重置为全额”。如果 autoRenew 为 null(续订状态未知),该字段仍可能包含日期——请勿将其描述为有保证的重置时间。除非 autoRenew 为 true,否则绝不要告诉用户“你的额度将在 重置”。当 autoRenew 为 false 时,应将 period.end 日期表述为到期日,例如“你的订阅将于 到期;自动续订已关闭,因此除非续订,否则套餐将失效”——而不是将其说成重置时间。

qianwen subscription orders — 订单历史(购买 / 续订 / 升级)

qianwen subscription orders --page 1 --page-size 100 --format json
qianwen subscription orders --from 2026-01-01 --to 2026-06-30 --type purchase --format json

选项:--page <n>(默认 1)、--page-size <n>(默认 20,最大 100)、--type purchase|renew|upgrade、--from / --to(YYYY-MM-DD)。

分页:结果按页返回。要获取完整历史记录,请从 --page 1 --page-size 100 开始,然后在 pagination.page × pagination.pageSize < pagination.total 时持续递增 --page,直到获取全部 pagination.total 条订单。

JSON 结构(根据 CLI 源码:orderType / status 为显示标签;amount 是带货币符号的显示字符串):

{
  "orders": [
    { "orderId": "20260701xxxx", "orderType": "Purchase", "orderTime": "2026-07-01 10:00:00", "amount": "¥199.00", "currency": "CNY", "status": "Paid" }
  ],
  "pagination": { "page": 1, "pageSize": 100, "total": 231 },
  "diagnostics": []
}

qianwen subscription tokenplan status — Token Plan 实例详情(周期、自动续订、席位摘要)

qianwen subscription tokenplan status --format json

JSON 结构(根据 CLI 源码;对应子调用失败时,period / autoRenew / renewable / seatSummary 为 null——请检查 diagnostics;额度值为十进制字符串):

{
  "product": "Token Plan Team Edition",
  "period": { "start": "2026-07-01", "end": "2026-08-01", "remainingDays": 3 },
  "autoRenew": { "enabled": true, "period": 1, "periodUnit": "M" },
  "renewable": { "canRenew": true, "interceptCode": null },
  "seatSummary": {
    "groups": [
      { "specType": "standard", "seats": 2, "assigned": 1, "totalValue": "50000", "surplusValue": "42000", "unit": "Credits", "nextCycleFlushTime": "2026-08-01" }
    ],
    "total": { "seats": 2, "totalValue": "50000", "surplusValue": "42000", "unit": "Credits" }
  },
  "diagnostics": []
}

如果四个数据字段均为 null,命令将以代码 1 退出(error 状态)。

⚠️ 只有 autoRenew.enabled 为 true 时,seatSummary.groups[].nextCycleFlushTime 才表示配额重置时间。 当 autoRenew.enabled 为 false(明确关闭自动续订)时,CLI 对所有分组返回的 nextCycleFlushTime: null。如果 autoRenew 本身为 null(状态未知),仍可能存在日期——请勿将其视为有保证的重置时间。只有在 autoRenew.enabled 为 true 时,才可以说“额度将于 重置”;当其为 false 时,应将 period.end 作为到期日,即套餐失效的日期,除非用户续订。

qianwen subscription tokenplan seats — 单席位详情和剩余额度(团队席位)

qianwen subscription tokenplan seats --page 1 --page-size 100 --format json
qianwen subscription tokenplan seats --spec-type standard --format json   # pro | standard

选项:--page <n>(默认 1)、--page-size <n>(默认 20,最大 100)、--spec-type pro|standard。分页规则与订单相同:当 page.current × page.size < page.total 时,持续递增 --page。

JSON 结构(根据 CLI 源码;cycle / config 可能为 null;cycle.surplusValue 是该席位当前周期的剩余额度):

{
  "page": { "current": 1, "size": 100, "total": 2 },
  "filter": { "specType": null },
  "items": [
    {
      "instanceCode": "tp-xxxxxxxx",
      "specType": "standard",
      "status": "NORMAL",
      "memberId": "12xxxxxxxxxxxx34",
      "assignable": true,
      "assignment": "assigned",
      "payMode": "Subscription",
      "productType": "TokenPlan",
      "cycle": { "startTime": "2026-07-01", "endTime": "2026-08-01", "totalValue": "25000", "surplusValue": "21000", "unit": "Credits" },
      "config": { "planType": "standard", "creditValue": 25000, "seatNum": 1, "quotaCycle": "MONTH" }
    }
  ],
  "diagnostics": []
}

输出和 Agent 展示规则

CLI 命令在 Agent / 管道环境中默认返回 JSON(auto 格式:TTY → 表格,管道 → json)。 JSON 是 Agent 的主要输出模式——始终显式传入 --format json,解析结构化响应,然后向用户展示人类可读的摘要。

JSON 输出示例(--format json)
qianwen 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 } }
  ],
  "token_plan": {
    "subscribed": true,
    "planName": "Token Plan Team Edition",
    "status": "valid",
    "totalCredits": 25000,
    "remainingCredits": 21000,
    "usedPct": 16,
    "resetDate": "2026-05-01",
    "addonRemaining": 8000
  },
  "pay_as_you_go": {
    "models": [
      { "model_id": "qwen3.6-plus", "usage": { "tokens_total": 480000 }, "cost": 0.38, "currency": "CNY" },
      { "model_id": "qwen-plus", "usage": { "tokens_total": 460000 }, "cost": 0.13, "currency": "CNY" }
    ],
    "total": { "cost": 0.51, "currency": "CNY" }
  }
}
文本输出示例(--format text)
qianwen 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
--------------------------------------------------------------------------

-- Token Plan  ·  Token Plan Team Edition - Standard Seat  ·  valid-------
Usage:      25K / 25K Credits
Quota Left: 100%
Status:     valid
Resets:     2026-06-01
--------------------------------------------------------------------------

-- 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 使用):

  1. 解析 JSON,提取与用户问题相关的数据
  2. 呈现易于理解的摘要——不要向用户直接输出原始 JSON
  3. 在摘要之后添加分析——用 --- 明确分隔

使用 --format text 时:

  1. 完全按原样显示 CLI 输出——不要修改或重新排版
  2. 保留所有格式——对齐、空格、进度条和分隔符
  3. 仅在输出之后添加分析——用 --- 明确分隔

绝不要:

  • ❌ 不加解释地向用户输出原始 JSON
  • ❌ 重新排版或总结文本/表格输出
  • ❌ 添加“以下是你的用量:”之类的前缀
  • ❌ 将文本/表格输出转换为项目符号列表

✅ 正确(JSON 模式):

Your QianWen usage for April:

**Free Tier**: qwen3.6-plus has 85% remaining (850K / 1M tokens), wan2.6-t2i has 76% remaining (38 / 50 images).
**Token Plan**: 16% used (21K / 25K Credits remaining).
**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...

✅ 正确(文本模式):

[CLI text output - exactly as-is]

---

**💡 Analysis**: Your qwen3.6-plus free tier is 85% remaining...

❌ 错误:

Here's your usage:
- qwen3.6-plus: 850K tokens remaining (85% left)

退出代码

代码含义
0成功
1通用/用法错误
2身份验证错误
3网络错误
4配置错误
130已中断
  • 退出代码非零时,仍应先尝试解析 stdout 中的结构化 JSON——其中可能包含可用的错误负载或部分结果。
  • 退出代码为 2(身份验证错误)时:引导用户完成身份验证流程,然后最多重试原始任务一次。绝不要反复尝试登录。

CLI 更新检查

当用户明确要求检查 CLI 更新时(例如“检查 CLI 更新”“检查 CLI 版本”或“CLI 是否有新版本”):

  1. 运行:qianwen version --check
  2. 报告结果。

QianWen CLI 会原生处理更新通知;此技能无需额外处理 stderr 信号。

实现说明

  • 按用量付费:API 仅返回总用量(不区分输入/输出)
  • Token Plan:按计划汇总额度消耗(不按模型细分)
  • logout:撤销服务端会话并清除本地凭据(密钥链和文件)。服务端调用尽力而为——本地登出始终会成功。
  • 身份验证:使用带 PKCE 的 OAuth 2.0 Device Authorization Grant。凭据在可用时存储于操作系统密钥链,否则回退到加密文件。
  • breakdown --model 为必填项:与先前的 Python 实现不同,CLI 要求 breakdown 指定 --model。若要查询所有模型的用量,请改用 qianwen usage summary。

评论

支持 Markdown