model-usage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Model usage

模型使用情况

Overview

概述

Get per-model usage cost from CodexBar's local cost logs. Supports "current model" (most recent daily entry) or "all models" summaries for Codex or Claude.
TODO: add Linux CLI support guidance once CodexBar CLI install path is documented for Linux.
从CodexBar的本地成本日志中获取单模型使用成本。支持为Codex或Claude生成“当前模型”(最新的每日记录)或“所有模型”的汇总信息。
待办事项:一旦CodexBar CLI的Linux安装路径文档完成,添加Linux CLI支持指南。

Quick start

快速开始

  1. Fetch cost JSON via CodexBar CLI or pass a JSON file.
  2. Use the bundled script to summarize by model.
bash
python {baseDir}/scripts/model_usage.py --provider codex --mode current
python {baseDir}/scripts/model_usage.py --provider codex --mode all
python {baseDir}/scripts/model_usage.py --provider claude --mode all --format json --pretty
  1. 通过CodexBar CLI获取成本JSON数据,或传入一个JSON文件。
  2. 使用捆绑的脚本按模型汇总数据。
bash
python {baseDir}/scripts/model_usage.py --provider codex --mode current
python {baseDir}/scripts/model_usage.py --provider codex --mode all
python {baseDir}/scripts/model_usage.py --provider claude --mode all --format json --pretty

Current model logic

当前模型逻辑

  • Uses the most recent daily row with
    modelBreakdowns
    .
  • Picks the model with the highest cost in that row.
  • Falls back to the last entry in
    modelsUsed
    when breakdowns are missing.
  • Override with
    --model <name>
    when you need a specific model.
  • 使用包含
    modelBreakdowns
    的最新每日记录行。
  • 选择该行中成本最高的模型。
  • 当细分数据缺失时,回退到
    modelsUsed
    中的最后一个条目。
  • 当需要特定模型时,可使用
    --model <名称>
    参数覆盖默认逻辑。

Inputs

输入

  • Default: runs
    codexbar cost --format json --provider <codex|claude>
    .
  • File or stdin:
bash
codexbar cost --provider codex --format json > /tmp/cost.json
python {baseDir}/scripts/model_usage.py --input /tmp/cost.json --mode all
cat /tmp/cost.json | python {baseDir}/scripts/model_usage.py --input - --mode current
  • 默认:执行
    codexbar cost --format json --provider <codex|claude>
    命令获取数据。
  • 文件或标准输入:
bash
codexbar cost --provider codex --format json > /tmp/cost.json
python {baseDir}/scripts/model_usage.py --input /tmp/cost.json --mode all
cat /tmp/cost.json | python {baseDir}/scripts/model_usage.py --input - --mode current

Output

输出

  • Text (default) or JSON (
    --format json --pretty
    ).
  • Values are cost-only per model; tokens are not split by model in CodexBar output.
  • 文本格式(默认)或JSON格式(使用
    --format json --pretty
    参数)。
  • 输出值仅为各模型的成本;CodexBar输出中未按模型拆分token数据。

References

参考资料

  • Read
    references/codexbar-cli.md
    for CLI flags and cost JSON fields.
  • 阅读
    references/codexbar-cli.md
    了解CLI参数和成本JSON字段。