Skip to main content
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,
) -> UsageSummary
Both parameters accept ISO-8601 dates or datetimes. Omit either to default to the current billing period.

Returns — UsageSummary

total_sessions
int
total_minutes
float
total_cost
float
Total cost in USD over the range.
breakdown
list[UsageByProvider]
Per-provider rollup — see below.
balance_micro_usd
string
Current organization balance in micro-USD (1_000_000 µ$ = $1), serialized as string so values beyond 2^53 survive JSON. Use int(summary.balance_micro_usd) when you need to do math.
balance_usd
float
Same balance, pre-divided for display convenience.

UsageByProvider

provider
string
type
'stt' | 'llm' | 'tts'
Modality.
metric
string
Billable unit (e.g. minutes, characters, tokens).
key_source
'BYOK' | 'MANAGED'
BYOK = customer key, no Speko margin. MANAGED = platform key, billed to the org.
quantity
float
cost
float
Cost 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}")