Skip to content

v0.3.1, long context pricing + meter.validate + retryCount

Latest

Choose a tag to compare

@ankitvirdi4 ankitvirdi4 released this 02 May 20:20

v0.3.1 patch with three small additive items.

Long context tier pricing

ModelPricing gains an optional longContext: { threshold, input, output } block. When inputTokens reaches the threshold, the entire input and output (and any cache rates that fall back to a multiple of input) are billed at the long context rates.

Anthropic Sonnet 4 family (4-0, 4-5, 4-6, 4-7) is now populated with standard $6 input / $22.5 output rates above 200k tokens.

computeCost('anthropic', 'claude-sonnet-4-6', 250_000, 50_000)
// = $2.625 (long context applies)
computeCost('anthropic', 'claude-sonnet-4-6', 100_000, 50_000)
// = $1.05 (base rate)

meter.validate()

Validates the structural integrity of the pricing table.

const meter = new Meter();
const issues = meter.validate({ provider: 'anthropic' });
// returns ValidationIssue[] with severity, provider, model, message

Catches malformed entries that may arrive via community PRs: zero or negative prices, broken longContext blocks, suspicious rate inversions. Also exports isModelKnown(provider, model) as a small public helper.

retryCount field

MeterEvent.retryCount is an optional field. Provider SDKs do not expose retry counts via stable hooks, so the wrap layer cannot auto populate it. Users who can capture retry count themselves can pass it through meter.record and we'll preserve it for analysis. README troubleshooting documents the current limitation.

Tests

232 unit tests, 99.45% line coverage. 16 new tests across long context pricing math, table validation, and retry preservation.