Agent skill

cost-report

Weekly API cost report — reads token usage CSV, computes dollar costs per skill and model, reports trends

Stars 152
Forks 17

Install this agent skill to your Project

npx add-skill https://github.com/aaronjmars/aeon/tree/main/skills/cost-report

SKILL.md

${var} — Number of days to cover (default: 7). Pass "30" for a monthly view.

Today is ${today}. Generate a cost report from Aeon's token usage data.

Model Pricing (per million tokens)

Use these rates to calculate costs. First check aeon.yml for the gateway.provider value.

Direct Anthropic (gateway.provider: direct)

Model Input Output Cache Read Cache Write
claude-opus-4-6 $15.00 $75.00 $1.50 $3.75
claude-sonnet-4-6 $3.00 $15.00 $0.30 $3.75
claude-haiku-4-5-20251001 $0.80 $4.00 $0.08 $3.75

Bankr Gateway (gateway.provider: bankr)

Model Input Output
claude-opus-4-6 $5.00 $25.00
claude-sonnet-4-6 $3.00 $15.00
claude-haiku-4-5-20251001 $0.80 $4.00
gemini-3-pro $1.25 $10.00
gemini-3-flash $0.15 $0.60
gpt-5.2 $2.50 $10.00
kimi-k2.5 $1.00 $4.00
qwen3-coder $0.50 $2.00

Note: Bankr does not break out cache read/write pricing separately. Treat cache columns as zero cost for Bankr rows.

For any model not in these tables, default to Opus pricing (conservative estimate).

Steps

  1. Determine the report window.

    • Default: 7 days. If ${var} is set to a number (e.g. "30"), use that many days.
    • Compute CUTOFF_DATE = today minus N days.
  2. Read token usage data.

    • File: memory/token-usage.csv
    • Columns: date,skill,model,input_tokens,output_tokens,cache_read,cache_creation
    • If the file does not exist: log "COST_REPORT_SKIP: no token-usage.csv yet" and stop — do NOT send any notification.
    • Filter rows where date >= CUTOFF_DATE.
    • If zero rows after filtering: log "COST_REPORT_SKIP: no runs in last N days" and stop.
  3. Compute costs for each row.

    For each row, look up the model's rates and calculate:

    input_cost  = input_tokens  / 1,000,000 × rate_input
    output_cost = output_tokens / 1,000,000 × rate_output
    cache_read_cost    = cache_read     / 1,000,000 × rate_cache_read
    cache_write_cost   = cache_creation / 1,000,000 × rate_cache_write
    row_cost = input_cost + output_cost + cache_read_cost + cache_write_cost
    
  4. Aggregate into report sections.

    a. Total cost for the window. b. Per-skill cost table — sum cost per skill, sort descending, show top 10:

    • Columns: Skill | Runs | Total Tokens | Cost | Avg Cost/Run c. Per-model breakdown — total cost and total tokens per model. d. Token efficiency — for each skill in top 10, compute output_tokens / total_tokens ratio (higher = more generative, less reading). e. Week-over-week trend — if window is 7 days and the CSV has ≥14 days of data:
    • Compare this week's total cost vs the prior 7-day period.
    • Show: "Cost up/down X% vs prior week" f. Most/least efficient skills (cost per 1K output tokens).
  5. Write the full report to articles/cost-report-${today}.md:

    markdown
    # Aeon Cost Report — ${today}
    *Period: last N days*
    
    ## Summary
    - **Total API cost:** $X.XX
    - **Total tokens:** X,XXX,XXX (input: X | output: X | cache_read: X | cache_write: X)
    - **Skill runs tracked:** N
    - **Week-over-week:** ↑/↓ X% vs prior week  (omit if <14 days of data)
    
    ## Cost by Skill (Top 10)
    | Skill | Runs | Tokens | Cost | Avg/Run |
    |-------|------|--------|------|---------|
    | ...   | ...  | ...    | $... | $...    |
    
    ## Cost by Model
    | Model | Runs | Tokens | Cost |
    |-------|------|--------|------|
    | ...   | ...  | ...    | $... |
    
    ## Efficiency
    | Skill | Cost / 1K Output Tokens |
    |-------|------------------------|
    | ...   | $...                   |
    
    *Generated by Aeon cost-report skill*
    
  6. Send notification via ./notify:

    *Cost Report — ${today} (last N days)*
    
    Total: $X.XX across N skill runs
    
    Top 3 by cost:
    1. skill-a — $X.XX (N runs, avg $X.XX/run)
    2. skill-b — $X.XX
    3. skill-c — $X.XX
    
    By model:
    - Opus: $X.XX | Sonnet: $X.XX | Haiku: $X.XX
    
    Trend: ↑/↓ X% vs prior week  [omit if no prior week data]
    
    Full report: articles/cost-report-${today}.md
    
  7. Log to memory/logs/${today}.md:

    ## Cost Report
    - Period: last N days
    - Total cost: $X.XX
    - Runs tracked: N
    - Most expensive skill: skill-name ($X.XX)
    - Cheapest skill: skill-name ($X.XX)
    - Week-over-week: +/-X%
    - Article: articles/cost-report-${today}.md
    - Notification sent via ./notify
    

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results