dsh-aliyun-quota: View Aliyun quota and spending in the DSH sidebar

Introduction

After using it extensively, the most common problem is not “how much it costs,” but “where to see it”: the balance goes to “My Benefits,” bills to “Fee Bills,” and model usage requires flipping through instance details, switching back and forth between a few pages. DSH’s philosophy is “everything is a plugin.” The dsh-aliyun-quota introduced below brings this query chain back to the sidebar: directly viewing available balance, coupons, bill trends, and token details by model within the DSH interface.

This plugin is maintained by 20132556, the owner of the GitHub repository 20132556/dsh-aliyun-quota. It is categorized as an Online Tool, has 1 star on GitHub, and is licensed under MIT. It has zero runtime dependencies and only calls the Aliyun official BSS OpenAPI. It is suitable for users who primarily use the DSH desktop interface and want to conveniently check their account status.

What it Provides

In short: Aliyun account “quota” and “spending” data, pulled from the BSS official interface and displayed in a sidebar panel.

  • Quota & Coupons: Account available balance (cash), available cash / credit limit, coupon face value and remaining, expiry reminders. Student vouchers (types like Cloud for You) are usually issued as coupons and will appear in the details.
  • Spending & Models: This month spent, today spent, last 8 months bill trend, monthly token usage, details by model / billing item.
  • The panel has two tabs: Spending & Models / Quota & Coupons. It refreshes sequentially every time, defaulting to an automatic refresh every 90 seconds, but you can also click “Refresh” manually.

The data sources correspond to the following interfaces, which are explicitly listed in the documentation.

Data Source Interface
Account Available Balance (Cash) QueryAccountBalance → AvailableAmount
Available Cash / Credit Limit QueryAccountBalance → AvailableCashAmount / CreditAmount
Coupon List (Face value, remaining, expiry, status, applicable products) QueryCashCoupons
Last N months billing summary (Spending, coupon deduction, discounts) QueryAccountBill (Granularity=MONTHLY)
Daily spending DescribeInstanceBill (Granularity=DAILY, once a day)
Token usage by model / billing item DescribeInstanceBill → InstanceID segments 3 and 4

The “by model” standard comes from the InstanceID format of Bailian (ModelScope): the 3rd segment is the model name, and the 4th segment is the billing item (Input / Output / Cache × Peak / Off-peak). The plugin aggregates based on these two segments, so it can tell you how much a specific model cost and how many tokens were used. Non-Bailian products (ECS, OSS, etc.) do not have this format; the plugin falls back to grouping by product name, which is normal behavior, not a bug.

Installation and Enablement

First, check the environment: package.json declares engines.dsh as >=0.2.1-rc.3 and engines.node as >=18. The plugin will not load as expected if the DSH version is lower than this.

The official installation command is (PowerShell):

dsh plugin --profile desktop add dsh-aliyun-quota

After installation, DSH Desktop must be restarted; the plugin loads during startup.

If the command doesn’t work, you can install from local source code:

git clone https://github.com/20132556/dsh-aliyun-quota.git
cd dsh-aliyun-quota
dsh plugin --profile desktop add link:<absolute path of this directory>

If that still doesn’t work, manually edit the two configurations in the profile and reinstall dependencies:

~/.dsh/profiles/desktop/package.json
  - Add "dsh-aliyun-quota": "<version or path>" to dependencies
  - Add "dsh-aliyun-quota" to dsh.profile.bundles
cd ~/.dsh/profiles/desktop
pnpm install

Restart DSH after making changes.

Configuring AccessKey

The plugin needs a pair of AccessKey to query data via the Aliyun official BSS OpenAPI. First, a note: this plugin runs with the permissions of the current DSH process, with the same read/write scope as the DSH process itself. Therefore, it is recommended to review the source code and license (MIT) before installing.

The steps to obtain the AK are suggested as follows in the documentation:

  1. Open RAM Access Control → AccessKey (https://ram.console.aliyun.com/manage/ak).
  2. Create a RAM user; do not use the main account AK—the main account AK has excessive permissions and a high risk of leakage.
  3. Grant this RAM user AliyunBSSReadOnlyAccess; read-only operations are sufficient for checking balance, coupons, and bills.
  4. Paste the AccessKey ID and Secret into the plugin panel and click “Save and Verify”.

Before saving, the plugin will actually call the interface to verify. If the verification fails, it will not be saved to disk, avoiding a pile of invalid keys. If using the main account AK, you must first confirm that the account is not restricted from calling the BSS OpenAPI.

Location and format of the key storage:

%USERPROFILE%\.dsh\dsh-aliyun-quota\config.json
{
  "accessKeyId": "LTAI5t...",
  "accessKeySecret": "..."
}

This file stores plaintext keys. If you do not want to save to disk, you can use environment variables instead. The plugin prioritizes reading environment variables, and the panel will display source: env:

setx ALIYUN_ACCESS_KEY_ID "LTAI5t..."
setx ALIYUN_ACCESS_KEY_SECRET "..."

Restart DSH after setting. “Settings → Clear Keys” in the panel will delete that config file.

Daily Usage

The operations after enabling are:

  1. Restart DSH Desktop.
  2. Click “Aliyun Quota” (the circular ¥ icon) in the left sidebar.
  3. On the first run, you will see the setup form; enter the AccessKey.
  4. It will display immediately after saving.

Things you can see on the Spending page: This month spent (summary of consumption amount by billing cycle, and how much is offset by coupons), today spent (from 0:00 to now), the last 8 months bill trend bar chart (hover to see details), this month’s token composition (Input / Cache Hit / Output proportions, including cache hit rate), expanded by model and billing item (Input·Peak, Input Cache·Off-peak, Output·Peak, etc.), listed separately by product, and daily details for this month (how much spent per day, how many tokens, how many details).

In addition, the plugin registers two tools, aliyun_quota and aliyun_usage, which can be used directly in the chat to ask about quota and spending, without needing to open the panel every time.

The server routes are mounted at /api/dsh-aliyun-quota/* and only allow local loopback access:

GET  /api/dsh-aliyun-quota/status?refresh=1   Quota overview
GET  /api/dsh-aliyun-quota/usage?refresh=1    Spending and model usage (can add &months=12)
GET  /api/dsh-aliyun-quota/config             Whether configured (does not return keys)
POST /api/dsh-aliyun-quota/config             Save and verify AccessKey
POST /api/dsh-aliyun-quota/clear              Clear keys
GET  /api/dsh-aliyun-quota/health             Self-check

Implementation Highlights and Data Freshness

The implementation method specified in the documentation: zero dependencies, using only node:crypto and node:fs, and manually writing the Aliyun RPC signature (HMAC-SHA1); no SDK installed; the server registers 5 routes, and the client uses the sidebar entry plus the main panel, mounted via ctx.slots, with no build steps. Regarding caching, quota is 45 seconds, bills are 5 minutes—bills require sending 30+ requests at once, so frequent refreshing is not advisable; concurrent requests are merged, the bill interface uses 6-way concurrency, and getting results for the last 8 months plus 30 days of details takes about 2 seconds.

Regarding freshness, pay attention: BSS bill generation usually has a 1–6 hour delay; money spent just now may not appear immediately, the same goes for the console. Right after the 1st of the month, the previous billing cycle may still be settling. To verify logic locally, you can run:

node test/routes.mjs

It will mount a temporary HTTP service, running 20 assertions with a fake DSH context, including “fake keys must be rejected and not saved to disk” and method validation for the usage route.

Common Troubleshooting

Symptom Cause Solution
No icon in sidebar Plugin not loaded Confirm dsh.profile.bundles in package.json contains it, restart DSH
Error “Key validation failed” when saving AK wrong / disabled / insufficient permissions Go to RAM console to check permissions
Error SignatureDoesNotMatch System clock deviation exceeds 15 minutes Calibrate system time
Shows “No coupons found” Coupon not arrived, or not of coupon type Wait a moment; Resource packages / Benefit packages use a different interface
Spending page always empty Bill not generated / insufficient permissions Wait 1–6 hours; confirm you have AliyunBSSReadOnlyAccess
Model shows as product name Non-Bailian product, InstanceID does not have this format Normal behavior
Error Throttling Refreshed too fast triggering rate control Wait 1 minute then click Refresh

When coupons cannot be found, three common reasons: the coupon has not arrived (after student certification approval, there may be a delay of a few minutes to a few hours); the benefit itself is a “Resource Package” or “Benefit Package”, which is not in QueryCashCoupons; insufficient RAM permissions. The bill interface requires bss:DescribeCoupons, bss:QueryBill, bss:DescribeInstanceBill, and AliyunBSSReadOnlyAccess already includes these permissions.

Uninstall

# 1. Remove from profile (both places need to be changed)
#    ~/.dsh/profiles/desktop/package.json
#      - Delete "dsh-aliyun-quota" from dependencies
#      - Delete "dsh-aliyun-quota" from dsh.profile.bundles
# 2. Reinstall dependencies
cd ~/.dsh/profiles/desktop
pnpm install
# 3. Restart DSH

Then delete the ~/.dsh/dsh-aliyun-quota/ directory, which contains the keys.

Conclusion

Its value lies in converging the Aliyun account quota and spending queries to the DSH sidebar, reducing the need to open several console pages, and providing token details by model, which the console bill page itself does not directly provide. Regarding the same interface data, BSS bills themselves have a 1–6 hour delay, and the plugin cannot circumvent this.

Directory page: https://www.skillhub.cn/plugins/20132556/dsh-aliyun-quota
Repository: https://github.com/20132556/dsh-aliyun-quota

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye