cost-report

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cost Report

成本报告

Generate a comprehensive cost report showing token usage, USD costs, and budget utilization for the specified period.
生成一份全面的成本报告,展示指定时间段内的令牌使用量、美元成本以及预算利用率。

When to use

使用场景

When you need to understand current spending -- how much each agent costs, which models consume the most budget, and whether you're on track to stay within budget.
当你需要了解当前支出情况时——比如每个Agent的成本是多少,哪些模型消耗的预算最多,以及你是否能在预算范围内控制支出。

Steps

操作步骤

  1. Retrieve usage -- call
    mcp__claude-flow__agentdb_hierarchical-recall
    to fetch token usage records from the
    cost-tracking
    namespace for the specified period (default: today)
  2. Compute costs -- for each record, calculate cost using model pricing:
    • Haiku: $0.25/M input, $1.25/M output
    • Sonnet: $3.00/M input, $15.00/M output
    • Opus: $15.00/M input, $75.00/M output
    • Include cache write/read costs where applicable
  3. Aggregate by model -- sum costs per model, compute percentage share
  4. Aggregate by agent -- sum costs per agent, include the model each agent used
  5. Check budget -- recall budget configuration and compute utilization percentage, check alert thresholds (50%/75%/90%/100%)
  6. Report -- display: total cost, budget remaining, model breakdown, agent breakdown, active alerts
  1. 获取使用数据——调用
    mcp__claude-flow__agentdb_hierarchical-recall
    接口,从
    cost-tracking
    命名空间中获取指定时间段(默认:今日)的令牌使用记录
  2. 计算成本——针对每条记录,根据模型定价计算成本:
    • Haiku:输入每百万令牌0.25美元,输出每百万令牌1.25美元
    • Sonnet:输入每百万令牌3.00美元,输出每百万令牌15.00美元
    • Opus:输入每百万令牌15.00美元,输出每百万令牌75.00美元
    • 适用时需包含缓存写入/读取成本
  3. 按模型汇总——统计每个模型的总成本,计算占比
  4. 按Agent汇总——统计每个Agent的总成本,包含各Agent使用的模型信息
  5. 检查预算——调取预算配置并计算利用率百分比,检查告警阈值(50%/75%/90%/100%)
  6. 生成报告——展示:总成本、剩余预算、模型成本明细、Agent成本明细、激活的告警信息

CLI alternative

CLI替代方案

bash
npx @claude-flow/cli@latest memory search --query "cost report for today" --namespace cost-tracking
bash
npx @claude-flow/cli@latest memory search --query "cost report for today" --namespace cost-tracking