← 返回 Skills 市场
leaofelipe

Anthropic Usage

作者 Felipe Leão · GitHub ↗ · v1.0.7 · MIT-0
cross-platform ✓ 安全检测通过
160
总下载
1
收藏
0
当前安装
8
版本数
在 OpenClaw 中安装
/install anthropic-usage
功能描述
Query Anthropic Admin API for token usage reports (daily, weekly, monthly) with model breakdown. Requires an Anthropic Organization account. Configure your A...
使用说明 (SKILL.md)

anthropic-usage

You are helping the user query their Anthropic token usage via the Admin API.

Before running anything

Check whether the API key is available:

[[ -n "${ANTHROPIC_ADMIN_API_KEY:-}" ]] && echo "KEY_EXISTS" || echo "KEY_MISSING"
  • If the output is KEY_MISSING: stop and guide the user through setup. Do NOT proceed until the variable is set.
  • If the output is KEY_EXISTS: proceed.

Setup guidance (show this when KEY_MISSING)

Tell the user they have two options:

Option 1 (recommended) — OpenClaw UI: Open the OpenClaw UI, go to Skills → anthropic-usage, enter the Admin API key in the API key field, and click Save key.

Option 2 — Edit ~/.openclaw/openclaw.json directly (for CLI users): Add the key under the skill entry:

{
  "skills": {
    "entries": {
      "anthropic-usage": {
        "enabled": true,
        "apiKey": "sk-ant-admin-..."
      }
    }
  }
}

The gateway picks up the change automatically — no restart needed.

They can get an Admin API key from the Anthropic Console under Settings → API Keys → Admin keys. Their account must be on an Organization plan to access usage reports.

Running the usage script

Once the key exists, run scripts/usage.sh with the appropriate flags based on what the user asked for:

User intent Command
Today's usage bash scripts/usage.sh --daily
This week bash scripts/usage.sh --weekly
This month bash scripts/usage.sh --monthly
Breakdown by model bash scripts/usage.sh --breakdown
Weekly + model breakdown bash scripts/usage.sh --weekly --breakdown
Monthly + model breakdown bash scripts/usage.sh --monthly --breakdown

Run the command from the skill's root directory (where scripts/ lives), or use the full path to scripts/usage.sh.

Formatting the output

After the script runs:

  1. Present the data as a friendly chat message, not a raw dump.
  2. Summarize the key numbers at the top (total input tokens, total output tokens).
  3. If --breakdown was used, render the per-model table in a readable way.
  4. Estimate the cost (agent-side step): The script returns token counts only — pricing is not included. After presenting the token data, use your web_fetch tool to fetch https://www.anthropic.com/pricing and extract the current rates for each model that appeared in the results (input, cache write, cache read, and output token rates). Calculate the estimated cost per model and the total. Present this as a cost summary after the token table. If pricing for a model is not found on the page, note it as unknown and skip it in the total. This fetch is intentional and scoped to anthropic.com.
  5. If the script exits with an error (non-zero exit code), show the error message and suggest fixes:
    • Exit 1 / "key file not found" → re-show setup guidance
    • "401 Unauthorized" → key is invalid or expired
    • "403 Forbidden" → key lacks Admin permissions or account is not on an Organization plan
    • Network error → ask the user to check their internet connection

Example friendly output

Here's your Anthropic usage for the past 7 days:

📥 Input tokens:   12,450,000
📤 Output tokens:    1,830,000
🔢 Total tokens:   14,280,000

Model breakdown:
| Model                     | Input tokens | Output tokens |
|---------------------------|-------------|---------------|
| claude-opus-4-6           |   8,200,000 |   1,100,000   |
| claude-sonnet-4-6         |   3,900,000 |     680,000   |
| claude-haiku-4-5-20251001 |     350,000 |      50,000   |

💰 Estimated cost (prices fetched live from anthropic.com/pricing):
| Model                     | Estimated cost |
|---------------------------|----------------|
| claude-opus-4-6           |        $152.40 |
| claude-sonnet-4-6         |         $18.72 |
| claude-haiku-4-5-20251001 |          $0.53 |
| **Total**                 |    **$171.65** |

Keep the tone helpful and concise.

安全使用建议
This skill appears to do exactly what it says: it uses your Anthropic Admin API key (sent only to api.anthropic.com) to fetch usage data and may fetch anthropic.com/pricing to estimate costs. Before installing or running: (1) Verify you provide an Admin API key (not a regular key) and that your account is on an Organization plan; (2) Inspect scripts/usage.sh locally if you want to confirm behavior — it uses curl and jq and follows pagination with sensible timeouts; (3) Be aware the agent will perform network calls to api.anthropic.com and anthropic.com when invoked (needed for functionality); (4) Ensure the OpenClaw web_fetch/tool used for pricing is restricted to anthropic.com as intended; (5) Do not paste your Admin key into untrusted places — use the OpenClaw UI key field or edit your local ~/.openclaw/openclaw.json if you understand the implications.
功能分析
Type: OpenClaw Skill Name: anthropic-usage Version: 1.0.7 The skill is a well-implemented tool for querying Anthropic Admin API usage reports. The core logic in `scripts/usage.sh` includes robust error handling, support for both GNU and BSD date utilities, and secure handling of the API key (using `set +x` to prevent leakage in shell traces). The agent instructions in `SKILL.md` are transparent and align with the stated purpose, including a functional step to fetch live pricing from `anthropic.com` for cost estimation. The package also includes a comprehensive test suite with mock fixtures, demonstrating high code quality and no evidence of malicious intent.
能力评估
Purpose & Capability
The skill name/description match the requested artifacts: it needs curl and jq and an Anthropic Admin API key, and includes a shell script that calls the Anthropic organizations usage_report endpoint. Nothing requested (binaries, env var) is unrelated to retrieving usage data.
Instruction Scope
The SKILL.md instructs the agent to check ANTHROPIC_ADMIN_API_KEY, run scripts/usage.sh, and (for cost estimation) fetch https://www.anthropic.com/pricing with the agent's web_fetch tool. The runtime instructions do not ask the agent to read unrelated files, exfiltrate data to third parties, or access unrelated credentials. The only external network calls described are to api.anthropic.com (usage API) and anthropic.com (pricing), which are consistent with the stated purpose.
Install Mechanism
No install spec is provided (instruction-only), and the repository only includes shell scripts and tests — there are no downloads from arbitrary URLs or extracted archives. This is low-risk from an install mechanism standpoint.
Credentials
The only required environment variable is ANTHROPIC_ADMIN_API_KEY (declared as primary). That is appropriate and proportionate for calling Anthropic's Admin API. The skill does not request other unrelated secrets or config paths.
Persistence & Privilege
The skill is not forced-always (always: false) and does not request elevated persistence or modification of other skills. It will run only when invoked.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install anthropic-usage
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /anthropic-usage 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.7
Add openclaw.json as alternative setup option for CLI users. UI remains recommended. No env var export.
v1.0.6
Clarify that cost estimation is an intentional agent-side web_fetch to anthropic.com/pricing, not a missing script feature. Resolves scanner inconsistency warning.
v1.0.5
Simplify setup: API key is now configured via the native UI field (Skills → anthropic-usage → API key). Remove manual openclaw.json editing and paste-in-chat instructions from SKILL.md and README.
v1.0.4
Add primaryEnv: ANTHROPIC_ADMIN_API_KEY to frontmatter so apiKey from openclaw.json is properly injected as env var and skill shows as available (not blocked) in the UI
v1.0.3
fix: add curl/jq to requires.bins metadata; add ClawHub badge to README
v1.0.2
Agent now fetches live Anthropic pricing page to estimate costs — no more hardcoded price tables
v1.0.1
docs: clarify config.patch merge semantics and baseHash requirement; address ClawHub security review feedback
v1.0.0
Initial release: daily/weekly/monthly token usage reports from Anthropic Admin API, with model breakdown, pagination support, and full test suite
元数据
Slug anthropic-usage
版本 1.0.7
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 8
常见问题

Anthropic Usage 是什么?

Query Anthropic Admin API for token usage reports (daily, weekly, monthly) with model breakdown. Requires an Anthropic Organization account. Configure your A... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 160 次。

如何安装 Anthropic Usage?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install anthropic-usage」即可一键安装,无需额外配置。

Anthropic Usage 是免费的吗?

是的,Anthropic Usage 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Anthropic Usage 支持哪些平台?

Anthropic Usage 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Anthropic Usage?

由 Felipe Leão(@leaofelipe)开发并维护,当前版本 v1.0.7。

💬 留言讨论