Skip to main content
The usage rollup. Aggregates every inference call you’ve made into buckets that the console charts on /usage. Free.

When to use

  • Build a custom spend chart outside the console
  • Detect a model-cost regression after switching model slug
  • Reconcile credits-headers against a wider window (per-call vs daily roll-up)
For balance movement (top-ups, refunds), see /me/billing/transactions. For per-call data (raw inference log items), wait for the per-call audit endpoint — not yet exposed in v1.

Request

curl 'https://llm.bytespike.ai/api/v1/me/usage?since=2026-05-01&until=2026-05-22&group_by=day' \
  -H "Authorization: Bearer $BYTESPIKE_API_KEY"

Query parameters

ParamTypeNotes
sincestringISO date / timestamp — bucket from this moment (inclusive). Default: 30 days ago.
untilstringISO date / timestamp — bucket until this moment (exclusive). Default: now.
group_bystringday (default) / hour / model / api_key. Combine via comma: ?group_by=day,model.
modelstringFilter to a single model slug.
api_keystringFilter to a single key (server-side resolved by key id; you can pass either the masked form or the key’s id).
since / until default windows cap at 90 days of history.

Response — group_by=day

{
  "buckets": [
    {
      "bucket": "2026-05-21",
      "total_usd": 4.18,
      "input_tokens": 142000,
      "output_tokens": 18400,
      "call_count": 312
    },
    {
      "bucket": "2026-05-20",
      "total_usd": 3.94,
      "input_tokens": 134800,
      "output_tokens": 17220,
      "call_count": 298
    }
    // …
  ],
  "totals": {
    "total_usd": 78.42,
    "input_tokens": 2580000,
    "output_tokens": 332000,
    "call_count": 5824
  }
}

Response — group_by=day,model

{
  "buckets": [
    {
      "bucket": "2026-05-21",
      "model": "claude-sonnet-4-6",
      "total_usd": 2.10,
      "input_tokens": 88000,
      "output_tokens": 11200,
      "call_count": 142
    },
    {
      "bucket": "2026-05-21",
      "model": "gpt-5-4",
      "total_usd": 1.74,
      "input_tokens": 42000,
      "output_tokens": 5800,
      "call_count": 96
    }
    // …
  ],
  "totals": { /* same shape */ }
}

Response fields

FieldTypeNotes
buckets[].bucketstringISO date (for day), ISO timestamp truncated to hour (for hour), or the dimension value (model id / key id).
buckets[].total_usdnumberBilled amount in this bucket.
buckets[].input_tokensintegerSum of input tokens.
buckets[].output_tokensintegerSum of output tokens.
buckets[].call_countintegerNumber of successful calls. Failed calls are free + excluded.
totalsobjectSame shape, summed across every returned bucket.

Errors

Statuserror.typeTrigger
400invalid_request_errorsince/until malformed, group_by unknown, or window > 90 days.
401authentication_errorMissing / revoked key.

Example — month-to-date by model

import requests, os, datetime

today = datetime.date.today()
since = today.replace(day=1).isoformat()
r = requests.get(
    "https://llm.bytespike.ai/api/v1/me/usage",
    params={"since": since, "group_by": "model"},
    headers={"Authorization": f"Bearer {os.environ['BYTESPIKE_API_KEY']}"},
    timeout=10,
).json()

for b in sorted(r["buckets"], key=lambda x: -x["total_usd"]):
    print(f"{b['model']:30s}  ${b['total_usd']:8.2f}  {b['call_count']} calls")