Query token metrics over a time range.
Reads hourly bucket files from disk and aggregates them into the Costs report with per-channel and per-model breakdowns. Every hour from the one containing from to the one containing to is included.
Costs
from
to
const june = getTokenMetrics({ from: '2026-06-01', to: '2026-06-30T23:59:59Z' });const lastWeek = getTokenMetrics({ from: new Date(Date.now() - 7 * 86_400_000) }); Copy
const june = getTokenMetrics({ from: '2026-06-01', to: '2026-06-30T23:59:59Z' });const lastWeek = getTokenMetrics({ from: new Date(Date.now() - 7 * 86_400_000) });
When from or to is not a valid date.
Query token metrics over a time range.
Reads hourly bucket files from disk and aggregates them into the
Costsreport with per-channel and per-model breakdowns. Every hour from the one containingfromto the one containingtois included.