Speko Docs

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,
) -> UsageSummary
await AsyncSpeko.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_sessionsint
total_minutesfloat
total_costfloat

Total cost in USD over the range.

breakdownlist[UsageByProvider]

Per-provider rollup — see below.

balance_usdfloat

Current organization balance in USD.

currency'USD'

UsageByProvider

providerstring
type'stt' | 'llm' | 'tts'

Modality.

metricstring

Billable unit (e.g. minutes, characters, tokens).

key_source'BYOK' | 'MANAGED'

BYOK = customer key, no Speko margin. MANAGED = platform key, billed to the org.

quantityfloat
costfloat

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}")

On this page