[FEATURE] Mods API: expose the billing fields of usage on ModelUsage / TurnUsage
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
ModelUsage (and so TurnUsage, $.model.fork/complete results, session.compact) carries only input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens. The API response, and the Agent tool's result type in the same API, also carry cache_creation.ephemeral_5m_input_tokens / ephemeral_1h_input_tokens, speed, inference_geo and service_tier.
A mod that prices requests can't tell from the main-thread usage:
- which TTL a cache write was billed at: it has to infer it from CLAUDE_CODE_PROMPT_CACHE_TTL / FORCE_PROMPT_CACHING_5M / promptCacheTtl, which breaks around TTL switches;
- whether a request ran in fast mode (2× rates) or with US-only inference (1.1×).
Proposed Solution
Add these as optional fields to ModelUsage, with the same names and shapes as in the Agent result's usage. For a turn's summed usage, cache_creation could be summed and speed / inference_geo / service_tier taken from the last response, as model already is.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
Developer tools/SDK
Use Case Example
Mod plugin to display a custom cost dashboard in a pane.
Additional Context
There's a partial workaround for speed. Fast mode is in the session's settings as fastMode (set by /fast) and readable with $.settings.read(), with CLAUDE_CODE_DISABLE_FAST_MODE ruling it out. That's the session's current setting, though, not what a given request was billed at: a /fast toggle while a request is in flight can make the two differ. There's no equivalent for inference_geo (no settings key or env var), and none for the cache_creation 5m/1h split.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗