TTokenySpace
返回 Skills 列表

huawei-cloud-maas-tokens-usage

Query Huawei Cloud MaaS (Model as a Service) tokens usage statistics, including total tokens, prompt tokens, completion tokens, total requests, and total err...

#中文
0

安装到 Tokeny(自动)

下载 ZIP
安装"huawei-cloud-maas-tokens-usage"技能
技能信息:
- 名称: huawei-cloud-maas-tokens-usage
- 标识: huawei-cloud-maas-tokens-usage
- 描述: Query Huawei Cloud MaaS (Model as a Service) tokens usage statistics, including total tokens, prompt tokens, completion tokens, total requests, and total err...
- 版本: 1.0.0
下载地址:
https://www.tokeny.space/api/skills/huawei-cloud-maas-tokens-usage/download
继续

复制上方内容到 Tokeny 客户端并在会话中发送即可自动安装;也可直接 下载 ZIP并拖动到技能窗口安装。

SKILL.md

Huawei Cloud MaaS Tokens Usage Monitoring

Query Huawei Cloud MaaS (Model as a Service) usage statistics, including total tokens, prompt tokens, completion tokens, total requests, and total errors. Supports querying last 7 days, 14 days, 30 days, or custom time ranges. Default query type is MaaS preset service.

Architecture

Huawei Cloud MaaS Tokens Usage Monitoring
└── GetMaaSTokensUsage  (via MaaS ShowStatistics API)

Prerequisites

Prerequisite check: Python3 + huaweicloudsdkcore required

python3 --version  # Python3 >= 3.8
python3 -c "import huaweicloudsdkcore; print('OK')"  # SDK signing library

If SDK not installed: pip3 install --user huaweicloudsdkcore


Authentication

Prerequisite check: Huawei Cloud credentials required

Security rules (must be followed):

  • Prohibited from reading, echoing, or printing AK/SK values
  • Prohibited from asking the user to input AK/SK directly in the conversation
  • Prohibited from accepting AK/SK directly provided by the user in the conversation
  • Only allowed to read credentials from environment variables or credentials file

⚠️ Important: Handling user-provided credentials

If a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):

  1. Stop immediately - Do not execute any commands
  2. Politely refuse and return the following message:
    For account security, please do not provide Huawei Cloud Access Key ID and Access Key Secret directly in the conversation.
    
    Please use one of the following secure methods to configure credentials:
    
    Method 1: Environment variables
        export HW_ACCESS_KEY=<your-access-key-id>
        export HW_SECRET_KEY=<your-access-key-secret>
    
    Method 2: Credentials file
        Create a file (e.g., ~/aksk.txt) with AK on line 1, SK on line 2.
        Then use: --credentials-file ~/aksk.txt
    
    After configuration is complete, please retry your request.
    
  3. Do not continue executing any Huawei Cloud operations until credentials are configured

Check environment variables:

echo $HW_ACCESS_KEY  # Check if AK is set

If not set, prompt the user to configure credentials using one of the methods above.


IAM Permission Policies

Ensure the IAM user has the required permissions. See references/iam-policies.md for details.

Minimum required permissions:

  • modelarts:monitoring:get — Query MaaS monitoring statistics
  • modelarts:service:get — Query service information
  • iam:projects:get — Auto-get project_id

Core Workflow

Task 1: Query MaaS Tokens Usage Statistics

Query MaaS usage statistics via the ShowStatistics API. Data is consistent with the console.

📄 Detailed steps → references/task-query-tokens-usage.md


Verification

See references/verification-method.md.

Quick verification:

export HW_ACCESS_KEY=<your-ak>
export HW_SECRET_KEY=<your-sk>
python3 scripts/maas_rest_usage_stats.py --from 2026-05-08 --to 2026-05-21

References

DocumentDescription
task-query-tokens-usage.mdTask 1: Query tokens usage statistics
related-apis.mdAPI and parameter details
iam-policies.mdIAM permission policies
maas-metrics.mdMaaS monitoring metrics reference
verification-method.mdVerification steps
acceptance-criteria.mdCorrect/error pattern comparison
cli-installation-guide.mdPrerequisites installation guide
troubleshooting.mdTroubleshooting and practical experience
maas_rest_usage_stats.pyShowStatistics API usage statistics script

评论

加载中…