/** * Subset of Anthropic API's `usage` object as it appears in jsonl `assistant` entries. * Older sessions may lack `cache_creation` sub-object (only flat counts); newer ones split 5m vs 1h. */ export interface ClaudeUsage { input_tokens?: number; output_tokens?: number; cache_creation_input_tokens?: number; cache_read_input_tokens?: number; cache_creation?: { ephemeral_5m_input_tokens?: number; ephemeral_1h_input_tokens?: number; }; } export interface ModelPricing { inputPerMTok: number; outputPerMTok: number; cacheCreation5mPerMTok: number; cacheCreation1hPerMTok: number; cacheReadPerMTok: number; } /** * Pricing table per Anthropic public rates (USD per 1M tokens). Keyed by model **family** * (sonnet-4 / opus-4 / haiku-4), not specific revisions — revisions within a family share rates. * * If Anthropic publishes a price change, update here and bump the comment block date. * Last verified: 2026-05-15. * * Rate references (Anthropic public pricing, Claude 4 family): * sonnet-4: $3 input, $15 output, $3.75 cache-write-5m, $6 cache-write-1h, $0.30 cache-read * opus-4: $15 input, $75 output, $18.75 cache-write-5m, $30 cache-write-1h, $1.50 cache-read * haiku-4: $1 input, $5 output, $1.25 cache-write-5m, $2 cache-write-1h, $0.10 cache-read */ export declare const PRICING_TABLE: Record; /** * Map a full Anthropic API model id (e.g. "claude-sonnet-4-5-20250929") to a pricing family key. * Returns null for unrecognized strings — caller treats null as "cost unknown" rather than zero. */ export declare function normalizeModelId(modelId: string | null | undefined): string | null; export interface CostBreakdown { input: number; output: number; cacheCreation5m: number; cacheCreation1h: number; cacheRead: number; } export interface CostResult { totalUsd: number; modelFamily: string; breakdown: CostBreakdown; } /** * Reverse-derive USD cost from a Claude `usage` object and the model id used for that message. * Returns null when the model family is unknown — callers must handle null explicitly (do not * silently fall through to zero, which would understate spend). * * Cache creation rule: prefer `cache_creation.ephemeral_{5m,1h}_input_tokens` split; if absent, * fall back to treating the flat `cache_creation_input_tokens` count as 5m (conservative lower bound). * * @see DR-0012 §3.4 — per-message cost is summed across a turn by adapter-tui.ts using msg.id dedup. */ export declare function usageToCost(usage: ClaudeUsage | null | undefined, modelId: string | null | undefined): CostResult | null;