usage
GET /v1/usage — billing and usage reporting.
Usage summary for the current billing period. Exposed via speko.usage.
summary = speko.usage.get()
print(summary.total_sessions, summary.total_minutes, summary.total_cost)
print(summary.balance_usd)Signature
Speko.usage.get(
*,
from_date: str | None = None,
to_date: str | None = None,
) -> UsageSummaryawait AsyncSpeko.usage.get(
*,
from_date: str | None = None,
to_date: str | None = None,
) -> UsageSummaryBoth parameters accept ISO-8601 dates or datetimes. Omit either to default to the current billing period.
Returns — UsageSummary
total_sessionsinttotal_minutesfloattotal_costfloatTotal cost in USD over the range.
breakdownlist[UsageByProvider]Per-provider rollup — see below.
balance_usdfloatCurrent organization balance in USD.
currency'USD'UsageByProvider
providerstringtype'stt' | 'llm' | 'tts'Modality.
metricstringBillable unit (e.g. minutes, characters, tokens).
key_source'BYOK' | 'MANAGED'BYOK = customer key, no Speko margin. MANAGED = platform key, billed to the org.
quantityfloatcostfloatCost in USD for this row.
Example — last 24 hours
from datetime import datetime, timedelta, timezone
now = datetime.now(timezone.utc)
yesterday = now - timedelta(hours=24)
summary = speko.usage.get(
from_date=yesterday.isoformat(),
to_date=now.isoformat(),
)
for row in summary.breakdown:
print(f"{row.type}\t{row.provider}\t{row.quantity}{row.metric}\t${row.cost}")