
Huawei Cloud Maas Tokens Usage
Query Huawei Cloud MaaS token consumption over a chosen window without hardcoding AK/SK or using unsupported API parameters.
Overview
Huawei Cloud MaaS Tokens Usage is an agent skill for the Operate phase that runs the documented REST usage script with correct service types, credential patterns, and time ranges.
Install
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-maas-tokens-usageWhat is this skill?
- REST script maas_rest_usage_stats.py with --from/--to date ranges
- service-type 1 (My Service), 2 (Preset Service), and 4 (Custom Endpoint)—not 3
- Credentials via HW_ACCESS_KEY/HW_SECRET_KEY env vars or --credentials-file (line, comma, or KEY=VALUE formats)
- Explicit distinction between “last 7 days” and “this month” when interpreting user requests
- Security pattern: never ask for AK/SK in chat and never hardcode secrets in code
- service-type values 1, 2, and 4 supported; value 3 returns 400
- three credentials-file formats documented (per-line, comma-separated, KEY=VALUE)
Adoption & trust: 2 installs on skills.sh; 5 GitHub stars; trending (+200% hot-view momentum).
What problem does it solve?
You need Huawei MaaS token usage for a specific period but keep hitting 400 errors, leaking AK/SK, or mis-reading “last 7 days” as “this month.”
Who is it for?
Indie builders operating Huawei Cloud MaaS who want scripted token stats with security and parameter guardrails baked into the agent workflow.
Skip if: Teams not on Huawei Cloud, or anyone who wants to paste AK/SK into chat instead of local env or --credentials-file setup.
When should I use this skill?
User asks for Huawei Cloud MaaS token usage, billing windows, or REST usage statistics for preset, custom, or my-service endpoints.
What do I get? / Deliverables
You get a reproducible usage pull using env or file credentials and API-supported service_type values, ready to log under your ops notes or cost review.
- CLI invocation with validated --from/--to and --service-type
- Usage statistics output suitable for cost or monitoring notes
Recommended Skills
Journey fit
Token-usage reporting is a production ops task: you run it after models are live to watch spend and spot anomalies. Monitoring is the canonical shelf because the skill pulls REST usage stats and enforces correct time-range semantics for dashboards and alerts.
How it compares
Use instead of hand-rolled curl against MaaS usage APIs without the documented service_type and credential acceptance rules.
Common Questions / FAQ
Who is huawei-cloud-maas-tokens-usage for?
Solo and indie builders running inference on Huawei Cloud MaaS who need agent-guided REST usage reporting with correct auth and date windows.
When should I use huawei-cloud-maas-tokens-usage?
In Operate when monitoring spend or usage trends; also when reconciling monthly bills or answering “how many tokens did we burn last 7 days?” before scaling or throttling.
Is huawei-cloud-maas-tokens-usage safe to install?
The skill explicitly forbids collecting AK/SK in conversation and hardcoding secrets; review the Security Audits panel on this page before trusting any third-party skill in production.
SKILL.md
READMESKILL.md - Huawei Cloud Maas Tokens Usage
# Acceptance Criteria: Correct/Error Pattern Comparison ## Script Parameter Patterns ### service_type Values **Correct:** Use 1, 2, 4 ```bash --service-type 2 # Preset Service --service-type 1 # My Service --service-type 4 # Custom Endpoint ``` **Error:** Use 3 (API does not support) ```bash --service-type 3 # Returns 400 error ``` ### Credential Provision **Correct:** Environment variables or credentials file ```bash export HW_ACCESS_KEY=xxx && export HW_SECRET_KEY=xxx python3 scripts/maas_rest_usage_stats.py --from 2026-05-08 --to 2026-05-21 python3 scripts/maas_rest_usage_stats.py --from 2026-05-08 --to 2026-05-21 --credentials-file /path/to/aksk.txt ``` **Error:** Hardcode AK/SK in code ```python ak = "WTEBXXXXXX" sk = "xxxxxxxxxx" ``` ### Credentials File Format **Correct:** Supports the following formats ``` # One value per line <AK> <SK> # Comma-separated <AK>,<SK> # KEY=VALUE format HW_ACCESS_KEY=<AK> HW_SECRET_KEY=<SK> ``` ## Security Standards ### Credential Handling **Correct:** Guide users to configure credentials themselves ``` Please set environment variables HW_ACCESS_KEY and HW_SECRET_KEY Or use --credentials-file to specify a credentials file ``` **Error:** Ask users for AK/SK in conversation ``` Please tell me your AK and SK ``` ## Time Range Standards **Correct:** Strictly distinguish "last 7 days" and "this month" - "last 7 days": now-7d ~ now - "this month": 1st of month ~ now **Error:** Confuse time ranges - User says "last 7 days" but calculate as "this month" ## Timezone Standards **Correct:** Follow OS local timezone, auto-detect **Error:** Hardcode CST/Asia/Shanghai # Prerequisites Installation Guide ## Python3 + huaweicloudsdkcore ```bash # Check Python3 version python3 --version # Requires >= 3.8 # Install SDK signing library pip3 install --user huaweicloudsdkcore # Verify python3 -c "import huaweicloudsdkcore; print('SDK OK')" ``` ## Credentials Configuration ### Method 1: Environment variables (recommended) ```bash export HW_ACCESS_KEY=<your-access-key-id> export HW_SECRET_KEY=<your-access-key-secret> ``` ### Method 2: Credentials file Create a file supporting three formats: ``` # One value per line <AK> <SK> # Comma-separated <AK>,<SK> # KEY=VALUE format HW_ACCESS_KEY=<AK> HW_SECRET_KEY=<SK> ``` Usage: `--credentials-file /path/to/aksk.txt` > **Security reminder:** > - Never provide AK/SK directly in conversation > - Never hardcode AK/SK in scripts ## MaaS Service Regions | Region | Region ID | |--------|-----------| | Southwest-Guiyang-1 | cn-southwest-2 | > MaaS ShowStatistics API currently only supports Southwest-Guiyang-1 region. # IAM Permission Policy ## Required Permissions | Operation | Permission | Description | |-----------|-----------|-------------| | Query MaaS monitoring statistics | `modelarts:monitoring:get` | Call ShowStatistics API | | Query service information | `modelarts:service:get` | Get service list etc. | | Get project ID | `iam:projects:get` | Auto-get project_id | ## Minimum Permission Policy ```json { "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "modelarts:monitoring:get", "modelarts:service:get", "iam:projects:get" ] } ] } ``` ## Predefined Permission Policies - **ModelArts CommonOperations** — ModelArts common operations (includes `modelarts:service:get`, `modelarts:monitoring:get`) - **IAM ReadOnlyAccess** — IAM read-only access (includes `iam:projects:get`) # MaaS Monitoring Metrics Reference ## MaaS ShowStatistics API ### API `POST /v1/{project_id}/maas/monitoring/show-statistics` ### Response Metrics | Field | Type | Description | Unit | Conversion | |-------|------|-------------|------|------------| | `total_request_count` | Integer | Total request count | count | Use directly | | `total_error_count` | Integer | Total error count | count | Use directly | | `total_token