$npx -y skills add QwenCloud/qwencloud-ai --skill qwencloud-usage[QwenCloud] Manage account auth and query usage/billing. Use for: login, logout, check usage, view billing, free tier quota, coding plan status, pay-as-you-go costs. Skip for: model browsing, non-account tasks.
| 1 | # QwenCloud Usage |
| 2 | |
| 3 | Query QwenCloud usage, free tier quota, coding plan status, and pay-as-you-go billing. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | - **QwenCloud CLI** must be installed. Verify with: |
| 8 | |
| 9 | ```bash |
| 10 | qwencloud version |
| 11 | ``` |
| 12 | |
| 13 | If not installed, run: |
| 14 | |
| 15 | ```bash |
| 16 | npm install -g @qwencloud/qwencloud-cli |
| 17 | ``` |
| 18 | |
| 19 | Node.js >= 18 required. |
| 20 | |
| 21 | - Authentication: No configuration needed on first use. The CLI handles non-TTY detection and safe login automatically (see Authentication Flow below). |
| 22 | |
| 23 | ### Environment Variables |
| 24 | |
| 25 | | Variable | Description | |
| 26 | |-----------------------------|----------------------------------------------------------------------------------------------| |
| 27 | | `QWENCLOUD_KEYRING` | Set to `plaintext`, `no`, `0`, `false`, or `off` to opt out of OS keychain credential storage. | |
| 28 | | `QWENCLOUD_CREDENTIALS_DIR` | Override file-based credential directory (default: `~/.qwencloud/credentials`). | |
| 29 | |
| 30 | ## Authentication Flow (for Agents) |
| 31 | |
| 32 | The CLI auto-detects non-TTY environments and degrades safely — no wrapper script needed. |
| 33 | |
| 34 | ### TL;DR — 3-step auth path |
| 35 | |
| 36 | 1. `qwencloud auth status --format json` → `authenticated: true` → skip to commands |
| 37 | 2. `qwencloud auth login --init-only --format json` → extract `verification_url` → open in browser |
| 38 | 3. `qwencloud auth login --complete --format json` → poll until `success` event |
| 39 | |
| 40 | ### Quick check: already logged in? |
| 41 | |
| 42 | ```bash |
| 43 | qwencloud auth status --format json |
| 44 | ``` |
| 45 | |
| 46 | If `authenticated: true` and token is not expired, skip login entirely. |
| 47 | |
| 48 | ### Recommended: Two-phase login |
| 49 | |
| 50 | Works in all environments (desktop, headless, remote container). |
| 51 | |
| 52 | **Step 1 — Initialize login (non-blocking):** |
| 53 | ```bash |
| 54 | qwencloud auth login --init-only --format json |
| 55 | ``` |
| 56 | Exits immediately. Parse the stdout JSON `events` array: |
| 57 | - `already_authenticated` → user is logged in, skip to commands |
| 58 | - `device_code` → extract `verification_url` and present it to the user |
| 59 | |
| 60 | On desktop environments with a browser, open the URL for the user: |
| 61 | ```bash |
| 62 | open "$VERIFICATION_URL" # macOS |
| 63 | xdg-open "$VERIFICATION_URL" # Linux |
| 64 | start "" "$VERIFICATION_URL" # Windows |
| 65 | ``` |
| 66 | |
| 67 | **Step 2 — IMMEDIATELY start polling (do NOT wait for user confirmation):** |
| 68 | ```bash |
| 69 | qwencloud auth login --complete --format json |
| 70 | ``` |
| 71 | Parse the stdout JSON `events` array: |
| 72 | - `success` → login complete, proceed to commands |
| 73 | - `expired` → device code expired, go back to Step 1 |
| 74 | - `error` → report failure |
| 75 | |
| 76 | ### TTY environments (interactive terminal) |
| 77 | |
| 78 | If the agent is running in a TTY (e.g., user's terminal), simply run: |
| 79 | ```bash |
| 80 | qwencloud auth login |
| 81 | ``` |
| 82 | The CLI will automatically open the browser and poll until authorization completes. |
| 83 | |
| 84 | ### JSON event structure |
| 85 | |
| 86 | Both `--init-only` and `--complete` output a single JSON document: |
| 87 | ```json |
| 88 | { |
| 89 | "events": [ |
| 90 | {"event": "device_code", "verification_url": "...", "expires_in": 300}, |
| 91 | {"event": "success", "authenticated": true, "user": {"aliyunId": "..."}} |
| 92 | ] |
| 93 | } |
| 94 | ``` |
| 95 | |
| 96 | Event types: `already_authenticated`, `device_code`, `success`, `expired`, `error`, `pending`. |
| 97 | |
| 98 | ### NEVER: |
| 99 | |
| 100 | - ❌ Ask the user "Have you completed authorization?" before running `--complete` |
| 101 | - ❌ Wait for user confirmation before polling — run `--complete` immediately after presenting the URL |
| 102 | - ❌ Re-run `--init-only` without completing (this creates a new device code and invalidates the previous one) |
| 103 | |
| 104 | ## Usage |
| 105 | |
| 106 | All commands support `--format json` for structured, machine-parseable output (**recommended default**), and `--format text` for clean plaintext output. |
| 107 | |
| 108 | For agent use, **always prefer `--format json`** and parse the JSON response. Only fall back to `--format text` when the user explicitly requests human-readable plaintext. |
| 109 | |
| 110 | Never parse `table` format programmatically — it contains ANSI codes and Unicode borders. |
| 111 | |
| 112 | ### Auth Commands |
| 113 | |
| 114 | **`qwencloud auth status`** — Check current authentication state |
| 115 | |
| 116 | ```bash |
| 117 | qwencloud auth status --format json |
| 118 | ``` |
| 119 | |
| 120 | **`qwencloud auth logout`** — Revoke session server-side and clear local credentials |
| 121 | |
| 122 | ```bash |
| 123 | qwencloud auth logout |
| 124 | ``` |
| 125 | |
| 126 | ### Usage Commands |
| 127 | |
| 128 | **`qwencloud usage summary`** — View usage summary (free tier, coding plan, pay-as-you-go) |
| 129 | |
| 130 | ```bash |
| 131 | qwencloud usage summary # Current month |
| 132 | qwencloud usage summary --period last-month # Last month |
| 133 | qwencloud usage summary --from 2026-03-01 --to 2026-03-31 |
| 134 | qwencloud usage summary --format json # JSON output |
| 135 | ``` |
| 136 | |
| 137 | **Period presets**: `today`, `yesterday`, `week`, `month` (default), `last-month`, `quarter`, `year`, `YYYY-MM` |
| 138 | |
| 139 | **`qwencloud usage breakdown`** — View model usage breakdown |
| 140 | |
| 141 | ```bash |
| 142 | qwencloud usage breakdown --model qwen3.6-plus --days 7 |
| 143 | qwencloud usage breakdown --model qwen3.5-plus --pe |