AgentSkillsCN

anthropic-usage

随时查询Anthropic API的使用情况与费用,无论具体时间段为何。当用户询问Anthropic账户的API费用、用量、支出,或是账单详情时,这一工具都能轻松应对。支持自然语言表述的时间段,如“上周”、“昨天”、“2025年1月”,亦可指定具体日期或日期区间。

SKILL.md
--- frontmatter
name: anthropic-usage
description: Check Anthropic API usage and costs for any time period. Use when the user asks about API costs, usage, spending, or billing for their Anthropic account. Supports natural language periods like "last week", "yesterday", "january 2025", specific dates, or date ranges.

Anthropic API Usage

Fetch cost reports from the Anthropic Admin API.

Prerequisites

  • ANTHROPIC_ADMIN_KEY must be set in ~/.env

Usage

Run the script with a time period:

bash
~/.claude/skills/anthropic-usage/scripts/get_cost.py "<period>"

Supported Period Formats

FormatExampleDescription
Relative weeklast week, this week7-day periods
Relative monthlast month, this monthCalendar months
Relative dayyesterday, todaySingle days
Last N dayslast 3 days, last 30 daysRolling window
Specific date2026-02-01Single UTC day
Date range2026-01-01 to 2026-01-31Inclusive range
Month namejanuary, feb 2025Full calendar month

Options

  • --format table (default): Human-readable table with totals
  • --format json: Raw API response

Notes

  • Costs are returned in USD
  • Data is reported in UTC day buckets
  • The API returns amounts in cents; the script converts to dollars