← Back to Skills Marketplace
leaofelipe

Anthropic Usage

by Felipe Leão · GitHub ↗ · v1.0.7 · MIT-0
cross-platform ✓ Security Clean
160
Downloads
1
Stars
0
Active Installs
8
Versions
Install in OpenClaw
/install anthropic-usage
Description
Query Anthropic Admin API for token usage reports (daily, weekly, monthly) with model breakdown. Requires an Anthropic Organization account. Configure your A...
README (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.

Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install anthropic-usage
  3. After installation, invoke the skill by name or use /anthropic-usage
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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
Metadata
Slug anthropic-usage
Version 1.0.7
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 8
Frequently Asked Questions

What is Anthropic Usage?

Query Anthropic Admin API for token usage reports (daily, weekly, monthly) with model breakdown. Requires an Anthropic Organization account. Configure your A... It is an AI Agent Skill for Claude Code / OpenClaw, with 160 downloads so far.

How do I install Anthropic Usage?

Run "/install anthropic-usage" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Anthropic Usage free?

Yes, Anthropic Usage is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Anthropic Usage support?

Anthropic Usage is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Anthropic Usage?

It is built and maintained by Felipe Leão (@leaofelipe); the current version is v1.0.7.

💬 Comments