Skip to main content

Module usage

Module usage 

Source

Structs§

HookExecution
A single hook execution event from a type: "attachment" JSONL record where attachment.type == "hook_success".
ModelPricing
Pricing per 1M tokens (USD) by model family.
ParsedJsonl
Combined result from parsing a single JSONL file.
SessionUsage
Usage summary for a single session, returned to the frontend status bar.
UsageEntry
Flat row representing a single completed assistant turn.

Constants§

WEB_SEARCH_COST_PER_REQUEST
Flat fee per Anthropic web-search server-tool request ($10 per 1,000 = $0.01).

Functions§

context_window_for_model
Fable, Haiku 5.5+, Opus 5+ and Sonnet 5+ run a 1M window natively: JSONL strips the [1m] tag, yet 74 bare claude-opus-5*/claude-sonnet-5 sessions were observed sending requests over 200K. Opus/Sonnet 4.x stay 200K unless tagged [1m].
cost_for_entry
Single source of truth for per-turn cost (USD), used by both the live status bar (reduce_session) and the Usage page (commands::usage).
encode_project_path
Encode a project path the way Claude Code names its ~/.claude/projects/ folders (checked against Claude Code 2.1.287): every UTF-16 code unit that is not an ASCII letter or digit becomes -, and a name longer than 200 is cut to 200 and suffixed with - and a base-36 hash of the path.
fast_multiplier_for_model
Fast-mode (research preview) cost multiplier, applied to the entire token cost line when usage.speed == "fast". Fast mode is Opus-only and its premium varies by version (confirmed Anthropic pricing, 2026-09):
find_current_session_jsonl
Find the JSONL file for the current session by looking up Claude Code’s active sessions directory, matching on project path. Falls back to finding the newest JSONL created after spawned_at.
parse_jsonl_entries
Parse a single JSONL file into one UsageEntry per unique message.id.
pricing_for_entry
Per-turn rates: pricing_for_model, except Haiku 5.5+ turns whose prompt (input + cache reads + cache writes) exceeds 100k tokens, which bill the long-prompt tier.
pricing_for_model
Hardcoded as of 2026-10. Requires a code change + release when Anthropic updates pricing.
reduce_session
Reduce a list of UsageEntry for a single session into a SessionUsage.