AI disclosure: this is an AI-generated draft. The numeric fixture was compared with an existing reviewed source record, and the JavaScript below was executed. It is a historical arithmetic example, not current pricing or a provider recommendation.
Before multiplying usage by a price, make the counting convention explicit. If total input already includes cached reads, charging all input at the ordinary rate and then adding the cache fee counts that portion twice.
The fixture below is from a ten-request OpenOx record dated 19 September 2026 and reviewed on 24 September: requested model ID gpt-6-astra, account group GPT統一 / GPT限時車道, input 42,508 including 40,320 cached reads, and output 70 tokens. The historical per-million input / cached-read / output rates were USD 8 / 0.8 / 40. The requested model name does not establish the actual model behind the endpoint.
Save this as an .mjs file and run it with Node.js. It makes no API requests and needs no credentials.
import assert from 'node:assert/strict'; function reconcileSnapshot(s) { if (s.inputIncludesCache !== true) { throw new Error('Confirm that total input includes cached reads first'); } for (const n of [s.totalInput, s.cacheRead, s.output]) { if (!Number.isSafeInteger(n) || n < 0) throw new Error('Invalid token count'); } if (s.cacheRead > s.totalInput) throw new Error('Cached reads exceed input'); for (const n of [s.inputRate, s.cacheRate, s.outputRate, s.billed]) { if (!Number.isFinite(n) || n < 0) throw new Error('Invalid rate or charge'); } const uncached = s.totalInput - s.cacheRead; const expected = (uncached * s.inputRate + s.cacheRead * s.cacheRate + s.output * s.outputRate) / 1_000_000; return { uncached, expected: expected.toFixed(6), billed: s.billed.toFixed(6), delta: (s.billed - expected).toFixed(6) }; } const fixture = { inputIncludesCache: true, totalInput: 42508, cacheRead: 40320, output: 70, inputRate: 8, cacheRate: 0.8, outputRate: 40, billed: 0.052559, }; assert.deepEqual(reconcileSnapshot(fixture), { uncached: 2188, expected: '0.052560', billed: '0.052559', delta: '-0.000001', }); assert.throws(() => reconcileSnapshot({ ...fixture, cacheRead: undefined })); assert.throws(() => reconcileSnapshot({ ...fixture, inputIncludesCache: undefined })); assert.throws(() => reconcileSnapshot({ ...fixture, cacheRead: 42509 })); console.log('Historical calculation and invalid-input checks passed.'); The correct total is USD 0.052560, compared with the recorded charge of USD 0.052559. The difference is within the source record's display tolerance; the aggregate record does not identify a precise rounding cause. Incorrectly charging the whole input total at the ordinary rate and adding cached reads would produce USD 0.375120. That is a calculation mistake, not a claim that the provider actually charged it.
The six-decimal formatting is for display, not an implementation of production ledger precision. Different accounting conventions need different adapters. Preserve missing values as unknown, check whether multipliers are already applied, and match usage to charges from the same requests. Cache writes, tool costs, funding conversions and subscriptions require separate treatment when present.
Source and relationship: the dated AI Relay Check record. This draft is prepared for that site's account, and some provider links on the site have affiliate relationships. The source URL has no provider invitation code. The record does not validate current prices, model identity, other routes or a full client workflow.