usage GET /v1/usage — billing and usage reporting.
Get a usage summary for a billing period. Exposed via speko.usage.
const usage = await speko.usage. get ();
console. log (usage.totalSessions, usage.totalMinutes, usage.totalCost);
speko.usage. get (params ?: UsageQueryParams): Promise < UsageSummary >
Field Type Description fromstring?ISO-8601 start date. Omit to default to the current billing start. tostring?ISO-8601 end date. Omit to default to now.
Field Type Description totalSessionsnumberDistinct sessions in range. totalMinutesnumberTotal audio minutes billed. totalCostnumberTotal cost in USD: minutesCost + addOnCost. minutesCostnumberCost of the per-minute call rate. addOnCostnumberCost of everything billed on top of the minute: telephony, speech-to-speech backend tokens, numbers. breakdownUsageByProvider[]Per-provider rollup (see below). balanceUsdnumberCurrent organization balance in USD. currency'USD'Currency for balanceUsd and totalCost.
Field Type Description providerstringUpstream provider id. metricstringThe billable metric (e.g. session_seconds, llm_tokens, telephony_inbound_seconds). keySource'BYOK' | 'MANAGED'BYOK = customer key, no Speko margin. MANAGED = platform key, billed to org.chargeKind'minutes' | 'add_on' | 'included' | 'free' | 'byok'How the line bills: the per-minute rate, an add-on on top of it, covered by the minute, absorbed by Speko (post-call summaries), or run on your own key. quantitynumberBilled quantity in the metric's unit. costnumberCost in USD.
const now = new Date ();
const yesterday = new Date (now. getTime () - 24 * 60 * 60 * 1000 );
const usage = await speko.usage. get ({
from: yesterday. toISOString (),
to: now. toISOString (),
});
for ( const row of usage.breakdown) {
console. log ( `${ row . chargeKind } \t ${ row . provider } \t ${ row . quantity } ${ row . metric } \t $${ row . cost }` );
}