Skip to content

Commit b9caa13

Browse files
committed
docs(codex): document model metadata requirements
1 parent bce58fb commit b9caa13

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎apps/codex/CLAUDE.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
- `reasoning_output_tokens`: structured reasoning tokens counted separately by OpenAI.
1616
- `total_tokens`: either provided directly or recomputed as `input + output + reasoning`.
1717

18-
## Cost Calculation
18+
-## Cost Calculation
1919

2020
- Pricing is pulled from LiteLLM's public JSON (`model_prices_and_context_window.json`).
21-
- Default model is `gpt-5`; override via `--model` flag or `CODEX_USAGE_MODEL` env var.
22-
- Per-model pricing is fetched through the shared `LiteLLMPricingFetcher` with an offline cache macro for `gpt-5*` variants.
21+
- The CLI trusts the model metadata emitted in each `turn_context`. Sessions missing that metadata (observed in early September 2025 builds) should be skipped rather than attempting a fallback.
22+
- Per-model pricing is fetched through the shared `LiteLLMPricingFetcher` with an offline cache macro scoped to Codex-prefixed models. Aliases (e.g. `gpt-5-codex → gpt-5`) are handled in `CodexPricingSource` for pricing parity.
2323
- Cost formula per model/date:
2424
- Non-cached input: `(input_tokens - cached_input_tokens) / 1_000_000 * input_cost_per_mtoken`.
2525
- Cached input: `cached_input_tokens / 1_000_000 * cached_input_cost_per_mtoken` (falls back to input price when missing).

‎apps/codex/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ bunx @ccusage/codex monthly --json
4848
Useful environment variables:
4949

5050
- `CODEX_HOME` – override the root directory that contains Codex session folders
51-
- `CODEX_USAGE_MODEL` – default model name when a log entry is missing metadata
5251
- `LOG_LEVEL` – controla consola log verbosity (0 silent … 5 trace)
5352

53+
ℹ️ The CLI now relies on the model metadata recorded in each `turn_context`. Sessions emitted during early September 2025 that lack this metadata are skipped to avoid mispricing. Newer builds of the Codex CLI restore the model field, and aliases such as `gpt-5-codex` automatically resolve to the correct LiteLLM pricing entry.
54+
5455
## Features
5556

5657
- 📊 Responsive terminal tables shared with the `ccusage` CLI

‎docs/guide/codex/index.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ The CLI reads Codex session JSONL files located under `CODEX_HOME` (defaults to
2727
| `CODEX_HOME` | Override the root directory containing Codex session folders |
2828
| `LOG_LEVEL` | Adjust consola verbosity (0 silent … 5 trace) |
2929

30+
When Codex emits a model alias (for example `gpt-5-codex`), the CLI automatically resolves it to the canonical LiteLLM pricing entry. No manual override is needed.
31+
3032
## Next Steps
3133

3234
- [Daily report command](./daily.md)

0 commit comments

Comments
 (0)