Usage & analytics
Query spend, balance, and token usage programmatically with your API key — by model, by day, and by key.
Usage & analytics
Spend and usage are readable over the API with the same key you use for inference, under /v1/billing and /v1/usage. Use them to build your own dashboards, alert on burn rate, or attribute cost to a workload without instrumenting your application.
All of these are read-only GETs. Amounts are in micros — millionths of a dollar, so 61240000 is $61.24.
Endpoints
| Endpoint | Returns |
|---|---|
GET /v1/billing/balance | Credit balance and billing mode |
GET /v1/billing/summary | Spend and tokens over a window, by model, plus the balance |
GET /v1/billing/transactions | Ledger entries: charges, top-ups, credits. Team admins only |
GET /v1/usage/summary | Token, request, and cost totals over a window, by model |
GET /v1/usage/daily | The same per day and model, for charting |
GET /v1/usage/by-key | Spend per API key, and rolled up by key tag |
curl "https://api.sference.com/v1/billing/balance" \
-H "Authorization: Bearer $SFERENCE_API_KEY"{ "credit_balance_micros": 61240000, "billing_mode": "prepaid" }What a key can see
A key sees what its owner sees in the console:
| Key owner | Usage | Ledger |
|---|---|---|
| Team admin | The whole team; user_id narrows to one member | ✅ |
| Department head | Their department | ❌ 403 |
| Member | Their own | ❌ 403 |
The balance is the team's and is visible to every member. For a team-wide dashboard, use a key owned by a team admin.
Windows and filters
| Parameter | On | Meaning |
|---|---|---|
days | billing/summary, usage/* | Rolling window ending now. 1–365, default 30 |
month | usage/by-key | Calendar month YYYY-MM (UTC); overrides days |
tag | usage/by-key | Only keys with this tag |
user_id | usage/summary, usage/daily | Team admins: one member's usage |
limit, starting_after | billing/transactions | Page size (1–100, default 25) and the cursor from next_starting_after |
# Last 7 days, by model
curl "https://api.sference.com/v1/usage/summary?days=7" \
-H "Authorization: Bearer $SFERENCE_API_KEY"
# October, per key — the per-engineer view for coding agents
curl "https://api.sference.com/v1/usage/by-key?month=2026-10" \
-H "Authorization: Bearer $SFERENCE_API_KEY"Attribution comes from the key, not the payload
Every request is attributed to the API key that made it. That is why one key per engineer, per service, or per workload is the simplest way to get useful breakdowns — no application instrumentation, no tagging in the request body.
A burn-rate alert
GET /v1/usage/daily returns one item per day and model.
from collections import defaultdict
import requests
def check_burn_rate(threshold_usd: float = 50.0):
r = requests.get(
"https://api.sference.com/v1/usage/daily",
headers={"Authorization": f"Bearer {SFERENCE_KEY}"},
params={"days": 7},
)
r.raise_for_status()
per_day = defaultdict(int)
for item in r.json()["items"]:
per_day[item["date"]] += item["cost_micros"]
if not per_day:
return
avg = sum(per_day.values()) / len(per_day) / 1_000_000
if avg > threshold_usd:
alert(f"sference burn rate is ${avg:.2f}/day, above ${threshold_usd:.2f}")In the console only
API keys are not accepted on /control/v1; those routes serve the console session and answer a key with 401. That covers the per-request activity log, the per-member and per-department reports, CSV exports, and top-ups — use the console for those.
Streams
A stream rolls up its own tokens and cost, which is the cleanest attribution when a workload spans many requests:
GET /v1/streams/{stream_id}total_cost_micros on the stream detail is the workload's spend in millionths of a dollar.
Decisions
Realtime classification with POST /v1/decisions — ask up to 64 choice, score, or yes/no questions about one input and get calibrated probabilities back in a single call.
Build with agent frameworks
Build agent loops on sference with LangChain, the OpenAI Agents SDK, and the Anthropic Agent SDK — and pick the window each step runs on.